i have a telerik menu control that can have an <ItemTemplate>
.
<telerik:RadMenuItem Text="Filter" Value="Search" >
<ItemTemplate>
<asp:TextBo开发者_开发百科x ID="TextBox1" runat="server""/>
</ItemTemplate>
</telerik:RadMenuItem>
how can i dynamically create the textbox itemTemplate in code behind?
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);
精彩评论