changing state of drop down list

  • Thread starter Thread starter luna
  • Start date Start date
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
 
You create the controls at run time rather in the design time....

You can try that....
 
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);
}
}
 
Back
Top