I have an asp.net drop down list that has a number of items, users are allowed to type some text into an asp.net textbox and javascript will filter the data in the drop down list. This all works perfectly until the user enters text that matches no item. When this occurs I create a new option in javascript with “no XXX found” with a value of “0”. The user the clicks an asp.net button and the page errors.
The error message i’m getting is:
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 theClientScriptManager.RegisterForEventValidationmethod in order to register the postback or callback data for validation.
Setting this to true does nothing, and I can’t figure out why the page would fall over on the postback.
Any ideas?
Setting
EnableEventValidation="false"will fix the problem, but open up the page to security holes.To solve the problem without causing security holes, call
ClientScriptManager.RegisterForEventValidation. For more details, please show us your code.