dynamic content template

4 posts, 0 answers
  1. Tia
    Tia avatar
    18 posts
    Member since:
    Mar 2013

    Posted 31 Jul 2013 Link to this post


    I have a radwindow in the aspx. During runtime how can I add a content template to it?

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 31 Jul 2013 Link to this post

    Hi Tia,

    Please have a look into the following code I tried which works fine at my end.

    <telerik:RadWindow ID="RadWindow1" runat="server" Width="350px" Height="350px">
    <telerik:RadButton ID="RadButton2" runat="server" Text="Add Content Template"

    protected void RadButton1_Click(object sender, EventArgs e)
        RadTextBox radtextbox1 = new RadTextBox();
        radtextbox1.Text = "Sample Text";
        RadButton radbutton1 = new RadButton();
        radbutton1.Text = "Click";
        RadWindow1.VisibleOnPageLoad = true;

  3. Stephen Rouse
    Stephen Rouse avatar
    23 posts
    Member since:
    Feb 2005

    Posted 02 Aug 2013 Link to this post

    I have a similar problem I am dynamically adding controls to a panel in the code behind, each control is a button which I have styled in the page, and want the new buttons to be similar. The code below is that being used in the web page;
    <telerik:RadButton runat="server" ID="RadButton6" Width="225" Height="40" CssClass="dialogclosebtn" RenderMode="Lightweight" Skin="MetroTouch" OnClick="CloseAddActivityRadButton_Click" ToolTip="Close this notification" Text="Test">
    <span class="btnText">Close Dialog</span>

    In the code behind, I have the following:
    private RadButton CreateButton(string title, string tooltip)
        RadButton rbtn = new RadButton();
        rbtn.Width = 225;
        rbtn.Height = 20;
        rbtn.CssClass = "dialogclosebtn";
        rbtn.RenderMode = RenderMode.Lightweight;
        rbtn.Skin = "MetroTouch";
        rbtn.Text = title;
        rbtn.ToolTip = tooltip;
        rbtn.Click += rbtn_Click;
        //rbtn.ContentTemplate =
        return rbtn;

    I am stuck at adding the content, but also the styling is not being applied.

    Kind Regards

    Steve Rouse

  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2013 Link to this post

    Hi Stephen,

    Please have a look into the following code I tried to add a RadButton ContentTemplate from C# code.

    protected void Page_Load(object sender, EventArgs e)
        RadButton6.ContentTemplate = new ButtonContentTemplate();
    public class ButtonContentTemplate : ITemplate
        void ITemplate.InstantiateIn(Control container)
            System.Web.UI.WebControls.Image contentImage = new System.Web.UI.WebControls.Image();
            contentImage.ID = "contentImage";
            contentImage.ImageUrl = "../Images/copy.png";
            contentImage.AlternateText = "envelope";
            Label contentLabel = new Label();
            contentLabel.ID = "contentLabel";
            contentLabel.CssClass = "btnText";
            contentLabel.Text = "E-Mail";

Back to Top