I recently started using ScriptManager. I have an ASP.NET DropDownList control that I'm populating via JavaScript. However, I'm using Event Validation. So I run into the error below if I don't use the "RegisterForEventValidation" call here for my dropdown. How do I know what value(s) to set in the second argument (where I have "value")? I am populating my dropdown via JavaScript, so I won't know what values are there from my code behind. I'm guessing that Render is called during an AJAX partial rendering postback, correct? Or is it not, so this is called regardless of whether I'm doing a full page postback or not. I guess I'm wanting to hear not only the answer to my question, but if you can share your experiences with me about the error below. I love input, just like Johnny #5.
==================
Code behind:
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Page.ClientScript.RegisterForEventValidation(DDLTest.UniqueID, "value")
MyBase.Render(writer)
End Sub
==================
Error:
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.
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 <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.
See Question&Answers more detail:os