Sunday, November 13, 2011

The confusing "Invalid postback or callback argument" error in an .aspx page.

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: 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.

Here is one possible condition, in which I could simulate this error :

You populate a GridView in Page_Load always. Instead normally you should do it only in case of post bacK :

       if ( !Page.IsPostBack)
            //.... code to populate the gridview
            pui.PopulateGrid(CustomerGridView, scmbl_cust.GetCustomerDataTable());

If you comment the !Page.IsPostBack, you will get the above error.

No comments:

Post a Comment