Populating text box from drop down list box - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Populating text box from drop down list box

AmnestyAmnesty Posts: 6Member
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

  • asp.netasp.net Posts: 1Member
    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
    :

  • singhrohit82singhrohit82 Posts: 33Member
    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.