changing state of drop down list

L

luna

is there a way of changing the state of a drop down list to a text box
depending on criteria ?
i could create a drop down list and a text box list in the same posistion
and change the visibility on criteria
- just wondered if there was another way

thanks
 
M

Madan Nayak

You create the controls at run time rather in the design time....

You can try that....
 
S

Shahar

Sure

// HTML
<form id=frmMain method=post runat="server">
<asp:panel ID="pnl" Runat="server">
</asp:panel>
</form>

// Code
private void Page_Load(object sender, System.EventArgs e)
{
if (true)
{
DropDownList list = new DropDownList();
list.Items.Add(new ListItem("text", "1"));
list.Items.Add(new ListItem("text", "2"));
pnl.Controls.Add(list);
}
else
{
TextBox txt = new TextBox();
pnl.Controls.Add(txt);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top