You do not check the drop-down list? You are checking the value selected by the user. This is almost the same advice as another post, since javascript or other tools can modify html or create your own POST, you should always check on the server side. Assume that all client requests are subject to change, and assume that the client-side check did not occur.
If you are using a web form model ...
If you just want to verify that the value is selected in the drop-down list myAjaxDropDown, use
<asp:RequiredFieldValidator id="dropdownRequiredFieldValidator"
ControlToValidate="myAjaxDropDown"
Display="Static"
InitialValue="" runat=server>
*
</asp:RequiredFieldValidator>
You can also look at asp: CustomValidator - for server side validation:
<asp:CustomValidator ID="myCustomValidator" runat="server"
onservervalidate="myCustomValidator_ServerValidate"
ErrorMessage="Bad Value" />
Both connect to the asp.net validation framework. for example, when you press a button with the nameSumbitButton
protected void myCustomValidator_ServerValidate(object source, ServerValidateEventArgs e)
{
e.IsValid = DropdownValueInRange(myAjaxDropDown.SelectedItem.Value);
}
protected void SubmitButton_Click( object source, EventArgs e )
{
Validate();
if( !IsValid )
return;
}
Some links for further reading: