Invalid postback or callback argument. Event validation is enabled using
Everseen the following error:
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. |
Well our team has seen this error quite a few times the last two days. On every screen where we had a gridview with buttons that were databinded, it appeared after we pushed the button.
Situation:
We have a list of orders and when we push the delete button we want a order from the list to disappear from our datastore as well as our screen.
Pretty straight forward, our implementation however had some quirks which we thought we had resolved them by databinding the GridView everytime the control was being posted. So in every Page_load the gridview.databind(); was being called, this worked for us for the last couple of months. Last week however this stopped working, don't ask me why it just did.
Our solution:
Make sure that you only do a databind() on the gridview in the !Page.IsPostBack part of your page_load. This way your gridview has its datasource binded and wil keep the information in its viewstate.
Now when you press the button on your gridview
- Handle the event, ie Delete item from datastore
- Reset your datasource of the gridview to reflect the changes to your datastore
- Call DataBind() on your gridview.
Posted on
23-11-2007
by Hans ter Wal
2 Comments
|
Trackback Url
|
Link to this post
Tags:
Web Development