Creating a Control Server Side

Last post 09-29-2014, 5:02 AM by danpc. 2 replies.
Sort Posts: Previous Next
  •  09-26-2014, 11:38 AM 80430

    Creating a Control Server Side

    I'm trying to create some Rich Text Editor controls server side (on page load) through .Net using "RTE.Editor rteSlide = new RTE.Editor();"

     

    Whislt the controls are visible and seem to work as expected some toolbar items (image gallery, insert image, template, etc...) cause the following error:


    Control '{Control ID}' Not Found
    at RTE.ap.c()

    at RTE.ap.Invoke() 

     

    any assistance would be appreciated.

     

    thanks 

    Filed under: ,
  •  09-27-2014, 6:17 AM 80431 in reply to 80430

    Re: Creating a Control Server Side

    Hi danpc,

     

    Did you set id for the editor control? Can you try the example page below? Does it work for you?

     

    1. <%@ Page Language="C#" AutoEventWireup="true" %>  
    2.   
    3. <%@ Register TagPrefix="RTE" Namespace="RTE" Assembly="RichTextEditor" %>  
    4.   
    5. <!DOCTYPE html>  
    6.   
    7. <html xmlns="http://www.w3.org/1999/xhtml">  
    8. <head id="Head1" runat="server">  
    9.     <title></title>  
    10.  <script runat="server">  
    11.      protected override void OnLoad(EventArgs e)  
    12.      {  
    13.          RTE.Editor myeditor = new Editor();  
    14.          myeditor.ID = "editor1";  
    15.          panel1.Controls.Add(myeditor);  
    16.          base.OnLoad(e);  
    17.      }  
    18.  </script>  
    19. </head>  
    20. <body>  
    21.     <form id="form1" runat="server">  
    22.     <asp:Panel ID="panel1" runat="server"></asp:Panel>  
    23.     </form>  
    24. </body>  
    25. </html>  
     

    Regards,

     

    Ken 

  •  09-29-2014, 5:02 AM 80432 in reply to 80431

    Re: Creating a Control Server Side

    The example you provided worked fine and there didn't seem to any difference between your code and the code I had written.

     

    It turns out the issue in my instance was the result of the objects only being created on Page Load when there was no postback. Due to the construction of the site we're building, postbacks (mostly asynchronous) occur fairly reguarly.

     

    I've changed the code so the editor is created on all page loads regardless of postback state.

     

    this resolves the issue (though i may need to address functionality of the page.

     

    thanks,

    Dan 

View as RSS news feed in XML