Our asp.net
webform has two DropDownLists
(DdlStatus
and DdlPlanStatus
) and a "Search" button with server-side code.
Initially, the page would work this way: If ListItem
"Plan" was selected in DdlStatus
(that's always visible), then DdlPlanStatus
would be displayed (using javascript
) and the user would select from this 2nd DropDownList
and do a search. If ListItem
"Complete" was selected in DdlStatus
, DdlPlanStatus
would be hidden and a search was made. This works fine.
The new change was that the 2nd dropdown (DdlPlanStatus
) would be visible with two ListItems
. So essentially, If ListItem
"Complete" was selected in DdlStatus
DdlPlanStatus
would have two ListItems
to select from.
So this is essentially my javascript
code:
function HideDropDown() {
var ddl = document.getElementById("<%=DdlStatus.ClientID%>");
var SelectedValue = ddl.options[ddl.selectedIndex].value;
var ddlParms = document.getElementById("<%=DdlPlanStatus.ClientID%>");
if ((SelectedValue) == "Complete") {
// ddlParms.style.display = "none"; //This was before, where I hid dropdown
document.getElementById("<%=DdlPlanStatus.ClientID%>").options.length = 0;
var opt = document.createElement("option");
opt.text = "Complete";
opt.value = "Complete";
document.getElementById("<%=DdlPlanStatus.ClientID%>").options.add(opt);
var opt2 = document.createElement("option");
opt2.text = "Missing";
opt2.value = "Missing";
document.getElementById("<%=DdlPlanStatus.ClientID%>").options.add(opt2);
}
else {
ddlParms.style.display = "block"; //display dropdown
}
}
When "Complete" is selected in 1st dropdown, I clear the contents of the 2nd dropdown and add 2 items, instead of just hiding it.
The issue is that when I run the search, I get error. I'm almost sure it's because I'm adding the items using javascript:
Invalid postback or callback argument. Event validation is enabled using
<pages enableEventValidation="true"/> in configuration or
<%@ Page EnableEventValidation="true" %> in a page.
Do I need to add those ListItems
another way?
Thanks.