3 Answers, 1 is accepted
0
                                
                                                    Shinu
                                                    
                                            
    Top achievements
    
            
                 Rank 2
                Rank 2
            
    
                                                
                                                answered on 31 Jul 2013, 09:45 AM
                                            
                                        Hi Tia,
Please have a look into the following code I tried which works fine at my end.
ASPX:
C#:
Thanks,
Shinu.
                                        Please have a look into the following code I tried which works fine at my end.
ASPX:
<telerik:RadWindow ID="RadWindow1" runat="server" Width="350px" Height="350px"></telerik:RadWindow><telerik:RadButton ID="RadButton2" runat="server" Text="Add Content Template"    OnClick="RadButton2_Click"></telerik:RadButton>C#:
protected void RadButton1_Click(object sender, EventArgs e){    RadTextBox radtextbox1 = new RadTextBox();    radtextbox1.Text = "Sample Text";    RadWindow1.ContentContainer.Controls.Add(radtextbox1);    RadButton radbutton1 = new RadButton();    radbutton1.Text = "Click";    RadWindow1.ContentContainer.Controls.Add(radbutton1);    RadWindow1.VisibleOnPageLoad = true;}Thanks,
Shinu.
0
                                
                                                    Stephen Rouse
                                                    
                                            
    Top achievements
    
            
                 Rank 1
                Rank 1
            
    
                                                
                                                answered on 02 Aug 2013, 01:53 PM
                                            
                                        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;
 
 
 
 
 
 
I am stuck at adding the content, but also the styling is not being applied.
Kind Regards
Steve Rouse
                                        <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"><ContentTemplate><span class="btnText">Close Dialog</span></ContentTemplate> </telerik:RadButton>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;    //Template     //rbtn.ContentTemplate =     return rbtn;}I am stuck at adding the content, but also the styling is not being applied.
Kind Regards
Steve Rouse
0
                                
                                                    Princy
                                                    
                                            
    Top achievements
    
            
                 Rank 2
                Rank 2
            
    
                                                
                                                answered on 06 Aug 2013, 09:15 AM
                                            
                                        Hi Stephen,
Please have a look into the following code I tried to add a RadButton ContentTemplate from C# code.
C#:
 
Thanks,
Princy.
                                        Please have a look into the following code I tried to add a RadButton ContentTemplate from C# code.
C#:
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";        container.Controls.Add(contentImage);        Label contentLabel = new Label();        contentLabel.ID = "contentLabel";        contentLabel.CssClass = "btnText";        contentLabel.Text = "E-Mail";        container.Controls.Add(contentLabel);    }}Thanks,
Princy.
