Skip to content

Invalid Postback or callback argument Event validation is enabled using Error

December 19, 2012

From an ASP.NET forum answer I gave earlier on today. See

If you ever encounter the following error, which I have seen several times: –

Server Error in ‘/’ Application.

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.

The reason the error is showing is because we rebind the data control in Page_Load every time which means that we will lose all of the posted data and viewstate. As a result, the ID of the button is different and when the event is validated there will be no matching unique id and hence event validation will fail. We are acutally raising an event for a button that is no longer in the control tree.

You can work around this by wrapping that code in if (!IsPostBack).

Might I add also to the answer to the forum page is that it can also be related to access to data in relation to ASP.NET permissions, if you are not given permission to view the data, Microsoft ASP.NET will throw this same error after being able to view a gridview table of data the user was allowed to view and then placing data in the same gridview which they don’t have permission to see.


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: