Invalid postback or callback argument. Event validation is enabled using ''

后端 未结 30 1815
生来不讨喜
生来不讨喜 2020-11-22 05:08

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

30条回答
  •  無奈伤痛
    2020-11-22 05:22

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

提交回复
热议问题