tags:

views:

103

answers:

1

i have a telerik menu control that can have an <ItemTemplate>.
suppose i have :

<telerik:RadMenuItem Text="Filter" Value="Search" > 
   <ItemTemplate> 
      <asp:TextBox ID="TextBox1" runat="server""/> 
   </ItemTemplate> 
</telerik:RadMenuItem>

how can i dynamically create the textbox itemTemplate in code behind?

+1  A: 

you could try this:

 class txtBox : ITemplate
 {
    public void InstantiateIn(System.Web.UI.Control container)
    {           
        System.Web.UI.WebControls.TextBox txt= new System.Web.UI.WebControls.TextBox();
        txt.ID = "123";         
        container.Controls.Add(txt);
    }
 } 

and then add it to the menu in this way:

    RadMenuItem i = new RadMenuItem();
    i.ItemTemplate = new SearchTextBox();
    RadMenu1.Items.Add(i);
scatman