Friday, March 25, 2011

Event Validation Error when switching between aspx pages

 In .Net web applications when you switch between pages very frequently sometimes you might observe exceptions (page breaks).

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.”

This problem occurs when post back happen before completely loading the previous page, to avoid this problem you need add following code under page element in web.config file
<pages  ValidateRequest="false"  EnableEventValidation="true" >
This will solve your problem; you don’t need to add these setting codes in all your aspx pages, if you have added it under page element in web.config then it will work for all the pages throughout the application.

No comments:

Post a Comment