How to use RenderControl correctly

Last post 06-14-2009, 9:39 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  06-14-2009, 3:28 AM 53128

    How to use RenderControl correctly

    Hi,
     
    I'm finishing the design of a DLL that will make use of a Html Editor and am currently evaluating CuteEditor (our first choice).
     
    I came into a problem that maybe somenone can easily help me. I have to create the CuteEditor Html Editor fields without any "code behind HTML", in other words, I cannot use the <CE:Editor> tag because they will all be compiled inside a .NET DLL class. As with any commom ASP.NET component, I tried the "classic" .NET procedure, as exemplified in the function below: 

    Function HtmlField() As String

    'Creates and configures the CUTEDITOR object
    Dim Editor1 As CuteEditor.Editor = New CuteEditor.Editor()
    Editor1.ID = "id_here"
    Editor1.Text = "Test Text"
    Editor1.ThemeType = CuteEditor.ThemeType.Office2007
    Editor1.AutoConfigure = CuteEditor.AutoConfigure.Simple
    Editor1.DisableItemList = "save"
    Editor1.EnableClientScript = True
    Editor1.EnableViewState = False

    'Render Output HTML using "classic" .NET architecture
    Dim sb As StringBuilder = New StringBuilder()
    Dim s As New System.IO.StringWriter(sb)
    Dim w As New System.Web.UI.HtmlTextWriter(s)
    Editor1.RenderControl(w)

    'Return HTML string of component
    Return sb.ToString()

    End Function

    In all tests I performed, the code above return only the "textbox" version of the CuteEditor, without any buttons or JS calls:
     
    Html output from function above:
     
    <!-- CuteEditor id_here Begin -->
    <textarea cols="50" rows="14" name="id_here" style="width:780px;height:320px;">Test Text </textarea>
    <!-- CuteEditor id_here End c0 ms0-->
     
    My question is, what am I doing wrong? Am I forgeting to set any specific Editor1 parameter before calling its RenderControl function? I really don't believe that CuteEditor is not compatible with this procedure because of its classical ASP version (that does exactly this), so I think I am missing something. Could someone, please, point me out at what it is?
     
    Thank you very much!
    Filed under: ,
  •  06-14-2009, 9:39 PM 53139 in reply to 53128

    Re: How to use RenderControl correctly

    Hi DanPaiva ,
     
    Editor can not use like that, you can try this way
     
    1. <%@ Page Language="vb" %>   
    2.   
    3. <html>   
    4. <head>   
    5.     <title>test</title>   
    6. </head>   
    7.   
    8. <script runat="server">   
    9.  Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)    
    10.     Dim Editor1 As New CuteEditor.Editor()    
    11.     Editor1.ID = "id_here"    
    12.     panel1.Controls.Add(Editor1)    
    13.     MyBase.OnLoad(e)    
    14. End Sub    
    15.       
    16. </script>   
    17.   
    18. <body>   
    19.     <form id="Form1" runat="server">   
    20.         <asp:Panel ID="panel1" runat="server">   
    21.         </asp:Panel>   
    22.     </form>   
    23. </body>   
    24. </html>  

    Regards,
     
    Ken
View as RSS news feed in XML