Populating text box from drop down list box

Hello,

I have a webform I built using ASP.net and C#. I have a drop down list box in my form. What I want to try and do is when the user selects a certain item in the drop down list box I would like to populate a text box depending on what the user selects. For example I have a question that ask the user to select their level of education and they select it from the drop down list box. If they happen to select "High School/GED" I would like to populate a text box with "N/A" and if they selected "College" I would like to keep the text box blank and have them fill in the type of degree they hold. How would I go about doing something like this? Any help would be great. Thank you

James

Comments

  • James,

    You can do like this.
    'High School/GED
    If dropdownlist1.selectedindex=0 then
    textbox.visible = true
    textbox.text="N/A"
    elseif dropdownlist1.selectedindex=1 then
    textbox.visible = true
    textbox.text=""
    end if



    : Hello,
    :
    : I have a webform I built using ASP.net and C#. I have a drop down list box in my form. What I want to try and do is when the user selects a certain item in the drop down list box I would like to populate a text box depending on what the user selects. For example I have a question that ask the user to select their level of education and they select it from the drop down list box. If they happen to select "High School/GED" I would like to populate a text box with "N/A" and if they selected "College" I would like to keep the text box blank and have them fill in the type of degree they hold. How would I go about doing something like this? Any help would be great. Thank you
    :
    : James
    :

  • Hi James,

    At first you need to set the AutoPostback Event of dropdown control to true. then on its "SelectedIndexChanged" Event. you can

    use

    ctrlname.selecteditem.text to check what value is selected and then u can show ur own custom text in the text box.



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories