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. Help Needed

Help Needed

Scheduled Pinned Locked Moved ASP.NET
helptutorial
4 Posts 3 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.
  • P Offline
    P Offline
    perms
    wrote on last edited by
    #1

    Hi, I have two dropdown list control, one has all the country values (USA,India,Japan etc.,) and another dropdown list control has a value of states ( CA,MA,WA,MD etc.,). i have one textbox to enter states name for non USA. if i select country as USA then the state dropdown list control should be enabled and the txtbox should be diabled. if i select country as othen then USA the state dropdown list control should be disabled and the txtbox should be enabled. how to achive this can anyone help Thanks Perumal Sethuraman

    H M P 3 Replies Last reply
    0
    • P perms

      Hi, I have two dropdown list control, one has all the country values (USA,India,Japan etc.,) and another dropdown list control has a value of states ( CA,MA,WA,MD etc.,). i have one textbox to enter states name for non USA. if i select country as USA then the state dropdown list control should be enabled and the txtbox should be diabled. if i select country as othen then USA the state dropdown list control should be disabled and the txtbox should be enabled. how to achive this can anyone help Thanks Perumal Sethuraman

      H Offline
      H Offline
      hakanaktan
      wrote on last edited by
      #2

      Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged DropDownList2.Enabled = False TextBox1.Enabled = False End Sub take it easy;) --junior coder--

      1 Reply Last reply
      0
      • P perms

        Hi, I have two dropdown list control, one has all the country values (USA,India,Japan etc.,) and another dropdown list control has a value of states ( CA,MA,WA,MD etc.,). i have one textbox to enter states name for non USA. if i select country as USA then the state dropdown list control should be enabled and the txtbox should be diabled. if i select country as othen then USA the state dropdown list control should be disabled and the txtbox should be enabled. how to achive this can anyone help Thanks Perumal Sethuraman

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        You can do that with some scripts on the client side. What you need to do is to add some scripts to enable/disable the state dropdownlist and textbox controls when the onchange event of the country dropdownlist is raised.

        function Country_Changed()
        {
        var country = window.document.getElementById("ddlCountry").value;
        if(country=="")
        {
        window.document.getElementById("ddlState").disabled = "disabled";
        window.document.getElementById("txtState").disabled = "disabled";
        }
        else if(country=="USA")
        {
        window.document.getElementById("ddlState").disabled = "";
        window.document.getElementById("txtState").disabled = "disabled";
        }
        else
        {
        window.document.getElementById("ddlState").disabled = "disabled";
        window.document.getElementById("txtState").disabled = "";
        }
        }

        To register the Country_Changed function for the onchange event, you can use the sample code below:

        ddlCountry.Attributes.Add("onchange", "Country_Changed();");

        In addition, you can also use some code on the server side to do that, but I think it is unlikely.

        1 Reply Last reply
        0
        • P perms

          Hi, I have two dropdown list control, one has all the country values (USA,India,Japan etc.,) and another dropdown list control has a value of states ( CA,MA,WA,MD etc.,). i have one textbox to enter states name for non USA. if i select country as USA then the state dropdown list control should be enabled and the txtbox should be diabled. if i select country as othen then USA the state dropdown list control should be disabled and the txtbox should be enabled. how to achive this can anyone help Thanks Perumal Sethuraman

          P Offline
          P Offline
          perms
          wrote on last edited by
          #4

          Thanks. both ideas or working. i greatly appriciate.

          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