chaitanya sai

chaitanya sai

  • 1.9k
  • 20
  • 453

Dynamically Add telerik editor div on asp.net c# button clic

May 24 2018 2:05 AM
in my requirement i have telerik editor, i have to add that telerik editor dynamically when we click on add button. Ex: if we click that button multiple times that editor add multiple times. I tried but i didnt get output. please help me. below is my tried code.
  1. <form id="form1" runat="server">  
  2. <div id="HtmlEditorDiv">  
  3. <div class="demo-containers">  
  4. <div class="demo-container">  
  5. <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />  
  6. <telerik:RadEditor ID="RadEditor1" runat="server" Width="100%" Height="500px" ToolbarMode="RibbonBar" EnableTrackChanges="True" ToolsFile="~/tools.xml" EnableComments="True" EditModes="Design,Preview">  
  7. </telerik:RadEditor>  
  8. </div> </div> </div>  
  9. <asp:Button ID="btnAdd" runat="server" Text="Add Button" OnClick="btnAdd_Click" />  
  10. <div id="divTextBox" style="border-color: Background; border-width: thick;" runat="server"></div>  
  11. </form>  
Aspx.cs file code
  1. protected void btnAdd_Click(object sender, EventArgs e)  
  2. {  
  3. // System.Web.UI.HtmlControls.HtmlGenericControl createDiv =  
  4. //new System.Web.UI.HtmlControls.HtmlGenericControl("div");  
  5. // createDiv.ID = "createDiv";  
  6. // createDiv.InnerHtml = "<telerik:RadScriptManager runat='server' ID='RadScriptManager1' /><telerik:RadSkinManager ID = 'RadSkinManager1' runat = 'server' ShowChooser = 'true' /><div class='demo-containers'><div class='demo-container'><telerik:RadEditor RenderMode = 'Lightweight' runat='server' ID='RadEditor1' SkinID='DefaultSetOfTools' Height='675px'></telerik:RadEditor></div></div><telerik:RadAjaxLoadingPanel runat = 'server' ID='RadAjaxLoadingPanel1'></telerik:RadAjaxLoadingPanel>";  
  7. // this.Controls.Add(createDiv);  
  8. //TextBox textName;  
  9. //textName = new TextBox();  
  10. //textName.TextChanged += new EventHandler(textName_TextChanged);  
  11. HtmlGenericControl div1 = this.FindControl("divTextBox"as HtmlGenericControl;  
  12. string Editoro= "<div id='HtmlEditorDiv1'><div class='demo-containers'><div class='demo-container'><telerik:RadEditor ID='RadEditor11' runat='server' Width='100%' Height='500px' ToolbarMode='RibbonBar' EnableTrackChanges='True'ToolsFile='~/tools.xml' EnableComments='True' EditModes='Design,Preview'></telerik:RadEditor></div></div></div>";  
  13. div1.InnerHtml = Editoro;  
  14. div1.Visible = true;  
  15. }