Drop Down Box Validation Problem

S

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
 
H

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" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top