I used a asp.net dropdownlist box and use OnSelectedIndexChanged event but when item selection has changed i am getting above 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.
I want a solution without disable event validation in page or web.config.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"></asp:DropDownList>
if(!IsPostBack)
{
DropDownList1.Items.Add(new ListItem("item1", "1"));
DropDownList1.Items.Add(new ListItem("item2", "2"));
DropDownList1.Items.Add(new ListItem("item3", "3"));
DropDownList1.Items.Add(new ListItem("item4", "4"));
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
var selItem = this.DropDownList1.SelectedItem;
}
How to resolve that exception. Any hints/sample is appreciable.