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. DropDown Validation Problem

DropDown Validation Problem

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-nettoolshelp
3 Posts 2 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.
  • A Offline
    A Offline
    Ajeet mittal
    wrote on last edited by
    #1

    I am working on asp.net 2.0 with c#, In my project there is a dropdown which having autopostback enabled. i have to validate its selection. i write javascript for it like that. <script type="text/javascript"> function alertOnBadSelection() { var select = document.getElementById('ddlContract').value; if (select=="-1") { alert('Please select contract'); return false; } else {return true;} } </script> this working fine as script when wrong selection,but when i select right selection dropdown's OnSelectedIndexChanged event not fire. can any one tell me how i will resolve my problem. thanks

    J 1 Reply Last reply
    0
    • A Ajeet mittal

      I am working on asp.net 2.0 with c#, In my project there is a dropdown which having autopostback enabled. i have to validate its selection. i write javascript for it like that. <script type="text/javascript"> function alertOnBadSelection() { var select = document.getElementById('ddlContract').value; if (select=="-1") { alert('Please select contract'); return false; } else {return true;} } </script> this working fine as script when wrong selection,but when i select right selection dropdown's OnSelectedIndexChanged event not fire. can any one tell me how i will resolve my problem. thanks

      J Offline
      J Offline
      J a a n s
      wrote on last edited by
      #2

      How you are calling the JavaScript function at client side? It should be like 'return alertOnBadSelection();' Make sure that AutoPostback property is true.

      *jayakrishnan

      A 1 Reply Last reply
      0
      • J J a a n s

        How you are calling the JavaScript function at client side? It should be like 'return alertOnBadSelection();' Make sure that AutoPostback property is true.

        *jayakrishnan

        A Offline
        A Offline
        Ajeet mittal
        wrote on last edited by
        #3

        Thanks for replying me. i am calling alertOnBadSelection() this function on onchange="return alertOnBadSelection();"like that. if it is working fine for wrong selection, but when i make right selection it not postback page. dropdown OnSelectedIndexChanged event not fire. can u hepl me on it. thanks

        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