Event validation issue with updatepanel "Invalid postback or callback argument"

2.5k views Asked by At

I am an UpdatePanel virgin and I'm having problems.

I have 2 drop down lists. I am basically trying to update the contents of the second drop down depending on what I select on the first drop down. In chrome this all works fine. In IE it doesn't seem to do anything the first time I change the drop down box selection and once I do it a second time it gives the error below.

I have read that I need to register the control for validation. So i tried the following.

protected override void Render(HtmlTextWriter writer)
        {
            Page.ClientScript.RegisterForEventValidation(DropDown1.UniqueID, "1");
            Page.ClientScript.RegisterForEventValidation(Dropdown2.UniqueID, "2");

            base.Render(writer);
        }

My two drop down boxes are within a user control so the Render code I have placed at the user control level but it doesn't seem to help. Is there some key thing I'm missing here?

Server Error in '/' Application.

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. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:

System.ArgumentException: 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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: 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.]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +8656758
System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +113
System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection) +55
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +13
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +327
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +878

0

There are 0 answers