1.11M Members

drop down list selection to enable text box

 
0
 

So I have a drop down list with various options, one being other. I want it so that if the user selects user the text box automatically appears. Ive placed the text box in a panel and set the visibility to false then added the following code :

    protected void dropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (dropDownList.SelectedItem.Value == "other")

            pnlText.Visible = true;

        else

            pnlText.Visible = false;

    }

however it doesn't work, when i select other from the drop down list the text box doesn't appear.

 
0
 

Did you set enable autopostback for the dropdown list?

 
0
 

No I hadn't, as soon as I posted I realised I hadn't set it. Got it working now.

 
0
 

great, good to hear you resolved it and that you confirmed that the autopostback fixed the problem so others that have a similar issue can benefit.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article