Click here to Skip to main content
15,907,236 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Apply validation on dropdownlist in asp.net???Give Me appropriate Answer
Posted
Comments
bbirajdar 25-Apr-12 9:29am    
@anilsrk...Are these answers given below appropriate? Please comment..
Sandeep Mewara 25-Apr-12 11:22am    
:)

Well, I assume you just want to validate that a specific item is not selected. Try using jQuery:

JavaScript
function validate() {
     if ($('#myDropDownList option:selected').val() == 'The wrong value') {
         return false;
      else
         return true;
}


On the onchange event of the drop down call the validate function.
 
Share this answer
 
 
Share this answer
 
You can try like this..


XML
<script runat="server">

    void btnSubmit_Click(Object sender, EventArgs e)
    {
        if (Page.IsValid)
            lblResult.Text = dropFavoriteColor.SelectedValue;
    }
</script>
 
Share this answer
 
I assume you just want to validate that a user changes the index of dropdown from 0 to 1 or more

Use required field validator and set the initialize property of your dropdownlist.

If this not helps feel free to ask the doubt
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900