Set first item in dropdownlist cannot be selected

Discussion in 'ASP.NET / ASP.NET Core' started by calvin, Jul 8, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi,

    Is anybody know how to make user unable to select the first item in dropdownlist, normally is "Please select..." on top of dropdownlist and how to validate the dropdownlist (Required field validator)if is selected or not.
    Thanks to all giving comments and suggestion.

    Calvin[?]
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    I don't think you can disable the first item on the drop down.

    You could use the Initial Value validation to make sure your user select something.

    Do something like this

    <asp:RequiredFieldValidator
    ControlToValidate="txtbox1"
    Text="Enter something"
    InitialValue="<Select One>"
    Runat="Server"
    />


    quote:Originally posted by calvin

    Hi,

    Is anybody know how to make user unable to select the first item in dropdownlist, normally is "Please select..." on top of dropdownlist and how to validate the dropdownlist (Required field validator)if is selected or not.
    Thanks to all giving comments and suggestion.

    Calvin[?]
    </blockquote id="quote"></font id="quote">
     
  3. quote:Originally posted by calvin

    Hi,

    Is anybody know how to make user unable to select the first item in dropdownlist, normally is "Please select..." on top of dropdownlist and how to validate the dropdownlist (Required field validator)if is selected or not.
    Thanks to all giving comments and suggestion.

    Calvin[?]
    </blockquote id="quote"></font id="quote">

    Add a required field validator. They are special for drop-downs... if a drop down is still equal to the initial value, it doesn ot pass validatiion.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page