I am getting the following error when I post back a page from the client-side. I have JavaScript code that modifies an asp:ListBox on the client side.
How do we fix
(1) EnableEventValidation="false"...................It does not work for me.
(2) ClientScript.RegisterForEventValidation....It does not work for me.
Solution 1:
Change Button/ImageButton to LinkButton in GridView. It works. (But I like ImageButton)
Research: Button/ImageButton and LinkButton use different methods to postback
Original article:
http://geekswithblogs.net/mahesh/archive/2006/06/27/83264.aspx
Solution 2:
In OnInit() , enter the code something like this to set unique ID for Button/ImageButton :
protected override void OnInit(EventArgs e) {
foreach (GridViewRow grdRw in gvEvent.Rows) {
Button deleteButton = (Button)grdRw.Cells[2].Controls[1];
deleteButton.ID = "btnDelete_" + grdRw.RowIndex.ToString();
}
}
Original Article:
http://www.c-sharpcorner.com/Forums/Thread/35301/