Huga
Huga

Reputation: 571

Dynamic text box generation from drop down list(C#)

Im using C# in VS 2010 to develop a web page.

the below is what i used to develop the dynamic text box for a certain drop down option...the problem im facing is that the text box is not being generated when i select the option.It is generated only when i clik a button or do some activity.

What changes should i do OR where to place the code to generate the text box as soon i select the option in the drop down control

        TextBox new_textbox = new TextBox();
        new_textbox.ID = "txt" + 1;
        new_textbox.Text = "";
        PlaceHolder1.Controls.Add(new_textbox);
        Label5.Visible = true;

Upvotes: 0

Views: 813

Answers (1)

giftcv
giftcv

Reputation: 1662

set AutoPostBack="True" in your dropdownlist

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">

When AutoPostBack Property is set to 'true' a postback to the server occurs automatically whenever the user selects an item from the list. By default it is set to 'false'.

Upvotes: 1

Related Questions