se the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation

tugberk picture tugberk · Apr 23, 2011 · Viewed 25.7k times · Source

guys, I have a usercontrol in my asp.net 3.5 application and I am passing some plain text on button click event. button is situated in the usercontrol. but when I fire the event, I am getting the following error;

Invalid postback or callback argument. Event validation is enabled using 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.

when I set the EnableEventValidation="false" to web form page like blow. it fires the event;

<%@ Page EnableEventValidation="false" %>

but I am thinking that it shouldn't be a good idea to set that false. So, what is the alternative here? there error saying that 'use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.' but where am I gonna register that thing? thanks !

Also, I am using some AjaxControlToolkit controls inside my usercontrol and some jquery stuff.

Answer

Mahmoud picture Mahmoud · Jun 27, 2012

try

if (!Page.IsPostBack)

before load and bind data in datagrid