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. validation on dropdown list

validation on dropdown list

Scheduled Pinned Locked Moved ASP.NET
helpquestion
7 Posts 5 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
    mdazeemuddin
    wrote on last edited by
    #1

    Hi i have dropdown list in my webpage and the code for the dropdown list is    i want to put some validation control on dropdownlist that is user should select one product without this it is not going submit i mean it will get message that please select one product how can i do this please help me

    A U S U 5 Replies Last reply
    0
    • M mdazeemuddin

      Hi i have dropdown list in my webpage and the code for the dropdown list is    i want to put some validation control on dropdownlist that is user should select one product without this it is not going submit i mean it will get message that please select one product how can i do this please help me

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Use JavaScript. On ClientClick of Submit button check DropDownList Text. If it "Blank" or "Select" the throw message and return false.

      cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

      1 Reply Last reply
      0
      • M mdazeemuddin

        Hi i have dropdown list in my webpage and the code for the dropdown list is    i want to put some validation control on dropdownlist that is user should select one product without this it is not going submit i mean it will get message that please select one product how can i do this please help me

        U Offline
        U Offline
        User 4250168
        wrote on last edited by
        #3

        U need to write the validation in java script for this to work. as follows function ddlValidation() { if (document.getElementById(.Selectedindex) == "-1" { alert('Select the item and proceed'); return false; } else return true; } if u want to show this message on click event of any button say 'Save' for example and id for the button is btnSave then call the above function from coding as follows btnSave.Attributes.Add("OnClick","javascript: return ddlValidation()"); try with this one....

        M 1 Reply Last reply
        0
        • M mdazeemuddin

          Hi i have dropdown list in my webpage and the code for the dropdown list is    i want to put some validation control on dropdownlist that is user should select one product without this it is not going submit i mean it will get message that please select one product how can i do this please help me

          S Offline
          S Offline
          saanj
          wrote on last edited by
          #4

          Ya, You can use JavaScript to validate the drop-down list. But side by side, you also should check it in the code-behind on the clieck event of the submit button. Though it will be a server side action, but if javascript will be disabled in the client's browser thn the server side code will do the trick for you. :)

          Either you love IT or leave IT...

          1 Reply Last reply
          0
          • U User 4250168

            U need to write the validation in java script for this to work. as follows function ddlValidation() { if (document.getElementById(.Selectedindex) == "-1" { alert('Select the item and proceed'); return false; } else return true; } if u want to show this message on click event of any button say 'Save' for example and id for the button is btnSave then call the above function from coding as follows btnSave.Attributes.Add("OnClick","javascript: return ddlValidation()"); try with this one....

            M Offline
            M Offline
            mdazeemuddin
            wrote on last edited by
            #5

            thanks for support how can i used this script in btnsave button i am using asp.net please give the aspbutton code onec again thanks for support

            1 Reply Last reply
            0
            • M mdazeemuddin

              Hi i have dropdown list in my webpage and the code for the dropdown list is    i want to put some validation control on dropdownlist that is user should select one product without this it is not going submit i mean it will get message that please select one product how can i do this please help me

              U Offline
              U Offline
              Uma J
              wrote on last edited by
              #6

              set the property as, AppendDataBoundItems="True" Select

              1 Reply Last reply
              0
              • M mdazeemuddin

                Hi i have dropdown list in my webpage and the code for the dropdown list is    i want to put some validation control on dropdownlist that is user should select one product without this it is not going submit i mean it will get message that please select one product how can i do this please help me

                U Offline
                U Offline
                Uma J
                wrote on last edited by
                #7

                set the property as, AppendDataBoundItems="True" Select if(DropDownlist1.selectvalue == "0") { response.write("Select atleast one value"); }

                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