I have two dropdown lists:
<asp:DropDownList ID="Field_Type" runat="server" />
<asp:DropDownList ID="Field_SubType" runat="server" />
Field_Type
is databound, with a list of types, populated from a database. Field_SubType
is set via jQuery / AJAX when Field_Type
is changed. I then add an option using $("#<%# Field_SubType.ClientID %>").append("<option value=\"1\">Test</option>");
. This works as expected (I see the new subtype added).
However, when posting back after selecting the option that has been added I get an error:
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.
What could be the cause of this, and how could I work round it? A few ideas I have:
- Use a plain
<select>
and useRequest.Form
- could be a problem if it is in a user control used multiple times on a page - Populate
Field_SubType
with all sub types, filtering out those that aren't a sub type ofField_Type
- this will load more data than required, which will add to page load time
Any other options?