'Invalid postback or callback argument, for dropdownlist
I get the following error when accessing my dropdownlist.
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.
Here is the dropdownlist code:
<div class="col s4">
<asp:DropDownList ID="organizationDropDownList" runat="server" AutoPostBack="true"
SelectMethod="GetOrganizations" DataTextField="Name" DataValueField="Id" AppendDataBoundItems="True" SelectedValue='<%# Bind("OrganizationId") %>'>
<asp:ListItem Value="-1">Select Student's School</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="organizationRequiredFieldValidator" runat="server"
ControlToValidate="organizationDropDownList" InitialValue="-1" ErrorMessage="<%$ Resources:Global, StudentSchoolRequired %>"
ToolTip="<%$ Resources:Global, StudentSchoolRequired %>" ValidationGroup="validationGroup">*</asp:RequiredFieldValidator>
</div>
Solution 1:[1]
It looks like you’re adding the listitems to the dropdownlist somewhere in your codebehind. Or even from javascript?
Anyhow, if such a value is selected, the framework doesn’t allow this, because it thinks it detects ‘tampering’ with the possible values of the list.
If you want to add values to the list, you should also register them using the scriptmanager via the method ‘RegisterForEventValidation’. (So this needs to be done for every possible value).
But maybe an easier solution would be populating the dropdownlist with an ObjectDataSource (for example). The framework takes care of registering the values for event validation..
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tim- |
