Drop Down Box Validation Problem

Discussion in 'ASP .Net Web Controls' started by sasquatch1000@gmail.com, Aug 14, 2006.

  1. Guest

    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
     
    , Aug 14, 2006
    #1
    1. Advertising

  2. HeavyMetal Guest

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

    wrote:
    > 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
     
    HeavyMetal, Aug 14, 2006
    #2
    1. Advertising

  3. guardsman85 Guest

    Thanks!
     
    guardsman85, Aug 22, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    784
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,035
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    498
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    284
  5. Replies:
    3
    Views:
    297
Loading...

Share This Page