我有一個html按鈕,我想要一個服務器端點擊事件,但是當按鈕被點擊並且頁面做回發時它不會觸發。該按鈕位於ItemTemplate
之內,<asp:ListView id="usersListView"/>
呈現信息表。OnServerClick for button not working
ASPX
<button runat="server" id="delete" class="btn btn-mini" title="Delete" OnServerClick="delete_Onclick"></button>
aspx.cs
protected void delete_Onclick(object sender, EventArgs e) {
ListViewItem listViewItem = (ListViewItem)((Button)sender).NamingContainer;
if(listViewItem != null) {
Membership.DeleteUser(((Label) listViewItem.FindControl("userName")).Text);
}
}
是'AutoEventWireup =「真」'在頁面聲明? – freefaller 2012-07-14 21:48:46