Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to validate dropdownlist

how to validate dropdownlist

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasevisual-studiojson
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mohd imran abdul aziz
    wrote on last edited by
    #1

    Dear All, i am making web application using asp.net ,C# (Visual studio 2005). i have dropdownlist with first listitem "Select one" and rest of the item comes form database I want to user should not select "Select one " option that is how can i validate dropdowmlist so that user should not select "Select one" Option. please Provide me some idea. Please help thanks

    regards imran khan

    S _ K 3 Replies Last reply
    0
    • M mohd imran abdul aziz

      Dear All, i am making web application using asp.net ,C# (Visual studio 2005). i have dropdownlist with first listitem "Select one" and rest of the item comes form database I want to user should not select "Select one " option that is how can i validate dropdowmlist so that user should not select "Select one" Option. please Provide me some idea. Please help thanks

      regards imran khan

      S Offline
      S Offline
      Sandeep Akhare
      wrote on last edited by
      #2

      OK there are many ways to do it most of go with javascript Write javascript code for that Check the dropdownlist selected index should not 0 if it then return false if not then return true very simple :)

      Thanks and Regards Sandeep

      1 Reply Last reply
      0
      • M mohd imran abdul aziz

        Dear All, i am making web application using asp.net ,C# (Visual studio 2005). i have dropdownlist with first listitem "Select one" and rest of the item comes form database I want to user should not select "Select one " option that is how can i validate dropdowmlist so that user should not select "Select one" Option. please Provide me some idea. Please help thanks

        regards imran khan

        _ Offline
        _ Offline
        _mubashir
        wrote on last edited by
        #3

        Hi, Just grab the onchange event of the dropdown in Javascript and validate. See the code below, function validate() { var e = document.getElementById("myDropDown"); if (e.selectedIndex == 0) // Select One is selected {Alert('some msg'); return false; } I assume 'Select One' is the first item on the drop down Thanks, Mubashir

        Every job is a self portrait of the person who did it.

        1 Reply Last reply
        0
        • M mohd imran abdul aziz

          Dear All, i am making web application using asp.net ,C# (Visual studio 2005). i have dropdownlist with first listitem "Select one" and rest of the item comes form database I want to user should not select "Select one " option that is how can i validate dropdowmlist so that user should not select "Select one" Option. please Provide me some idea. Please help thanks

          regards imran khan

          K Offline
          K Offline
          krishna19
          wrote on last edited by
          #4

          You can place a required filed validator. and after binding the drop down list, add the two lines: DropDownList1.Items.Insert(0,"Select One"); DropDownList1.Items[0].Value = "";

          If you fail for the first time , call it version 1.0.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups