Home All Groups Group Topic Archive Search About

Drop Down Box Validation Problem

Author
14 Aug 2006 4:45 PM
sasquatch1000
I am using Visual Web Developer 2005 Express Edition.

There is a drop down box on a webform that I would like to have
validated by a required field validation control.  The first item in
the list simply says "Select..."  Currently the required form
validation control allows "Select..." as a valid option.  How can I get
the validation control to flag this as an invalid selection and require
another item to be selected before submitting the form?

Thanks,
Owen

Author
14 Aug 2006 6:49 PM
HeavyMetal
try this:

<asp:DropDownList ID="ddl2" ValidationGroup="Validate"
AutoPostBack="false" Visible="true" runat="server" />

<asp:RequiredFieldValidator ID="vlddl2Required" Text="Required"
ControlToValidate="ddl2" ErrorMessage="Select"
ValidationGroup="Validate" runat="server"></asp:RequiredFieldValidator>

<asp:RangeValidator ID="vlddl2Range" ControlToValidate="ddl2"
ErrorMessage="Select a Company"  MaximumValue="15000000"
MinimumValue="0" Type="Integer" ValidationGroup="Validate"
runat="server" Text="Required"></asp:RangeValidator>


Put this on your page where you would like the messages displayed
<asp:ValidationSummary ID="vlSummary" ValidationGroup="Validate"
ShowMessageBox="true" runat="server" />

sasquatch1***@gmail.com wrote:
Show quoteHide quote
> I am using Visual Web Developer 2005 Express Edition.
>
> There is a drop down box on a webform that I would like to have
> validated by a required field validation control.  The first item in
> the list simply says "Select..."  Currently the required form
> validation control allows "Select..." as a valid option.  How can I get
> the validation control to flag this as an invalid selection and require
> another item to be selected before submitting the form?
>
> Thanks,
> Owen
Author
22 Aug 2006 3:52 AM
guardsman85
Thanks!