调用C#代码后面的函数,当我点击div显示的按钮时

时间:2014-12-22 10:09:36

标签: javascript c# jquery html asp.net

当用户点击按钮Button1_Click时,如何致电Button1

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" />

1 个答案:

答案 0 :(得分:0)

尝试,

protected void Button1_Click(object sender, EventArgs e)
{
   string script = "show(showdivslowly);";
   ClientScript.RegisterClientScriptBlock(this.GetType(), "Show", script, true);
}

使用RegisterClientScriptBlock而不是RegisterStartupScript方法。