Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否可以在javascript函数中将变量作为参数传递?_C#_Javascript_Asp.net_Treeview_Tree Nodes - Fatal编程技术网

C# 是否可以在javascript函数中将变量作为参数传递?

C# 是否可以在javascript函数中将变量作为参数传递?,c#,javascript,asp.net,treeview,tree-nodes,C#,Javascript,Asp.net,Treeview,Tree Nodes,我有这个功能: protected void mytv_SelectedNodeChanged(object sender, EventArgs e) { TreeView tv = sender as TreeView; var nid = tv.SelectedNode.Value; ScriptManager.RegisterStartupScript(this, this.GetType(), "anyname", "show(nid)", true); }

我有这个功能:

 protected void mytv_SelectedNodeChanged(object sender, EventArgs e)
 {
    TreeView tv = sender as TreeView;
    var nid = tv.SelectedNode.Value;
    ScriptManager.RegisterStartupScript(this, this.GetType(), "anyname", "show(nid)", true);
}
如您所见,我有一个变量nid,它根据单击的树节点获得不同的值1,2,3。
我可以将nid变量值作为参数直接传递给javascript函数show(nid)吗?
如果不是,我该怎么办

我的javascript函数如下所示:

function show(nid) 
{

    if (nid == 4) {
        alert('testing');
    }
    else
     {
         alert('what???');
     }
}

尝试连接:

ScriptManager.RegisterStartupScript(this, this.GetType(), "anyname", "show(" + nid + ")", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "anyname", "show(" + nid + ")", true);