Please Help with Code Behind

Last post 12-04-2005, 6:46 PM by Adam. 1 replies.
Sort Posts: Previous Next
  •  12-04-2005, 2:43 PM 13353

    Please Help with Code Behind

    I have found several examples using the html and the following method to display the editor and they work fine just not for what Im doing. The method that functioned used:

    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <CE:Editor id="Editor1" runat="server" ></CE:Editor>


    I am using Visual Studio .Net 2003.
     
    I have a webform named WebForm1; this was generated using the default asp application.
     
    I have added the control to my toolbar and a reference to the dll in my project references.
     
    I am now in the code behind the form
     
    This is what my code looks like:




    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      'Put user code to     initialize the page here
      Response.Write("Text Before Editor<br>")
      ShowAnEditor()
      Response.Write("<br>Text After Editor")
    End Sub

    Private Sub ShowAnEditor()
      Dim Editor As New CuteEditor.Editor
      Editor.Text = "This is a test"
      Dim sb As New System.Text.StringBuilder
      Dim sw As New System.IO.StringWriter(sb)
      Dim htw As New System.Web.UI.HtmlTextWriter(sw)
      Editor.RenderControl(htw)
      Response.Write(sb.ToString)

    End Sub


    The "ShowAnEditor" function fails with a null reference error. please assist. Remember I'm looking to place an editor with the call to a routine dynamically.



  •  12-04-2005, 6:46 PM 13354 in reply to 13353

    Re: Please Help with Code Behind

    Try the following code:


    Protected WithEvents Editor As CuteEditor.Editor

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      'Put user code to     initialize the page here
      Response.Write("Text Before Editor<br>")
      ShowAnEditor()
      Response.Write("<br>Text After Editor")
    End Sub

    Private Sub ShowAnEditor()
      Dim Editor As New CuteEditor.Editor
      Editor.Text = "This is a test"
      Dim sb As New System.Text.StringBuilder
      Dim sw As New System.IO.StringWriter(sb)
      Dim htw As New System.Web.UI.HtmlTextWriter(sw)
      Editor.RenderControl(htw)
      Response.Write(sb.ToString)
    End Sub



    Keep me posted
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML