We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,278 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

drop down list selection to enable text box

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.

2
Contributors
3
Replies
4 Hours
Discussion Span
6 Months Ago
Last Updated
4
Views
coder91
Junior Poster in Training
94 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Did you set enable autopostback for the dropdown list?

JorgeM
Industrious Poster
4,021 posts since Dec 2011
Reputation Points: 297
Solved Threads: 548
Skill Endorsements: 115

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

coder91
Junior Poster in Training
94 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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.

JorgeM
Industrious Poster
4,021 posts since Dec 2011
Reputation Points: 297
Solved Threads: 548
Skill Endorsements: 115

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0668 seconds using 2.63MB