我现在有非常简单的带有 Button 和 onclick 事件的代码。
问题是单击按钮会导致页面重新加载,并且不会触发单击事件中定义的操作。
这是我的代码:
<asp:CheckBoxList ID="chkContact" CssClass="panel-login" runat="server">
</asp:CheckBoxList>
<asp:Button ID="btnUpdate" Text=" Update " CssClass="button" runat="server" />
和事件:
protected void Page_Init(object sender, EventArgs e)
{
btnUpdate.Click += new EventHandler(btnUpdate_Click);
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
Response.Write("a" + chkContact.Items.Count.ToString());
}
这很奇怪。我已经做过很多次了,以前从来没有遇到过按钮问题。
我在这里错过了什么吗?