Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.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
Javascript 调用C codebehind函数,当我单击按钮时,div将显示_Javascript_C#_Jquery_Html_Asp.net - Fatal编程技术网

Javascript 调用C codebehind函数,当我单击按钮时,div将显示

Javascript 调用C codebehind函数,当我单击按钮时,div将显示,javascript,c#,jquery,html,asp.net,Javascript,C#,Jquery,Html,Asp.net,当用户单击按钮1时,如何调用按钮1\u Click 试试看 使用RegisterClientScriptBlock而不是RegisterStartupScript方法。但目前没有。您目前拥有的有点愚蠢。它将回发到服务器,然后服务器将处理服务器端单击事件,并将javascript发送到浏览器,当响应返回时,浏览器将运行javascript。您可能需要类似OnClientClick=showdivslow这样的东西,以避免请求/响应往返。请看,如果一致意见为否,则不应该! protected voi

当用户单击按钮1时,如何调用按钮1\u Click

试试看


使用RegisterClientScriptBlock而不是RegisterStartupScript方法。

但目前没有。您目前拥有的有点愚蠢。它将回发到服务器,然后服务器将处理服务器端单击事件,并将javascript发送到浏览器,当响应返回时,浏览器将运行javascript。您可能需要类似OnClientClick=showdivslow这样的东西,以避免请求/响应往返。请看,如果一致意见为否,则不应该!
protected void Button1_Click(object sender, EventArgs e)
{
    Page.ClientScript.RegisterStartupScript(this.GetType(), "id", "show(showdivslowly)", true);
}


<!-- language: lang-html -->
<div id="showdivslowly" runat="server" style="width: 500px; height: 200px; background-color: Blue; display: none">Welcome</div>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
{
   string script = "show(showdivslowly);";
   ClientScript.RegisterClientScriptBlock(this.GetType(), "Show", script, true);
}