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....
 
no, they are two different controls, you can 'transform' one into the other.
 
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

Back
Top