how to get the conents of editor on server side

Last post 04-28-2010, 2:18 AM by svk. 6 replies.
Sort Posts: Previous Next
  •  04-24-2010, 6:21 AM 60371

    how to get the conents of editor on server side

    i am trying out the cute editor for emailing purpose
     
    my code for sending email is on the button click on server side for which i have subject, frm and to
    i need the matter also to be send in the email
    how do i getthe matter of cthe cute editoe on the server side
     
    i tried with Editor1.text , but not getting anything the editor has runat server
     
    i get object refernce not set to instance of object
     
    2) when i type some matter in the editor and clcik on any other control the matter disappears
     
    3) how can i reduce the tools in the tool bar
     
     
     
  •  04-24-2010, 9:04 AM 60373 in reply to 60371

    Re: how to get the conents of editor on server side

    svk,
     
    You should use Editor.Text property to extract the content of editor. The reason you got the object reference not set to instance of object is causing you are using the wrong editor ID or other programming issues.
     
    Here is an example: Online email example
     
    The source code of this example can be found in the download pakcage. You can use it as a reference.
     
    >>3) how can i reduce the tools in the tool bar
     

    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

  •  04-25-2010, 8:53 AM 60382 in reply to 60373

    Re: how to get the conents of editor on server side

    i had usewd the same as well as tried usin request .form
    bt i am getting balnk in request .form methos and i get editor1.tet not deined
  •  04-25-2010, 4:55 PM 60385 in reply to 60382

    Re: how to get the conents of editor on server side

    Dear svk,
     
    Please use the following code:
    <%@ Page Language="C#" ValidateRequest="false"%>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <%@ import Namespace="System.Web.Mail" %>
    <html>
        <head>
      <title>ASP and ASP.NET WYSIWYG Editor - Online email example</title>  
     </head>
     <body>
            <form id="Form1" runat="server">   
       <table cellpadding="15">
        <tr>     
         <td>
          <h1>Online email example</h1>      
          <table>
           <tr>
            <td width="80">
              Subject:
             </td>
             <td>
              <asp:textbox id="SubjectTextBox" runat="server" value="Rich-text HTML email"></asp:textbox>
             </td>
            </tr>
            <tr>
             <td>
              From:
             </td>
             <td>
              <asp:textbox id="FromTextBox" runat="server"></asp:textbox>
              email address
              <asp:RegularExpressionValidator
               ControlToValidate="FromTextBox"
               Text="Invalid Email Address!"
               ValidationExpression="\S+@\S+\.\S{2,3}"
               Runat="Server"
              />  
              <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="'Email' must not be left blank." ControlToValidate="FromTextBox"></asp:RequiredFieldValidator>        
             </td>
            </tr>
            <tr>
             <td>
              To:
             </td>
             <td>
              <asp:textbox id="ToTextBox" runat="server"></asp:textbox>
              email address
              <asp:RegularExpressionValidator
               ControlToValidate="ToTextBox"
               Text="Invalid Email Address!"
               ValidationExpression="\S+@\S+\.\S{2,3}"
               Runat="Server"
              />  
              <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ErrorMessage="'Email' must not be left blank." ControlToValidate="ToTextBox"></asp:RequiredFieldValidator>        
                  
             </td>
            </tr>
           </table>               
           <CE:Editor  ThemeType="Office2003" URLType="Absolute" id="Editor1" Height="250px"  runat="server" ></CE:Editor><BR>
              
           <asp:Button id="btnUpdate" onclick="Submit" Runat="server" Text="Send email..."></asp:Button>
           <br /><br />
           <asp:Label id="ResultLabel" runat="server"></asp:Label>
         </td>
        <tr>
       </table>   
      </form>
     </body>
    </html>

    <script runat="server">
     void Page_Load(object sender, System.EventArgs e)
      {
         if (!IsPostBack)
      {
           Editor1.Text = "Type Here";
      }  
     }
     public void Submit(object sender, System.EventArgs e)
     { 
      if (Page.IsValid)
      {
       try
                {
                    SmtpMail.SmtpServer = "localhost";
                    MailMessage mail = new MailMessage();
                    mail.From = FromTextBox.Text;
                    mail.Subject = SubjectTextBox.Text;
                    mail.Body = Editor1.Text;
                    mail.To = ToTextBox.Text;
                    mail.BodyFormat = MailFormat.Html;
                    SmtpMail.Send(mail);
       
                    ResultLabel.Text = "Message sent successfully.";
                }
                catch (Exception exc)
                {
                    ResultLabel.Text = "<b>Message could not be sent: " + exc.Message + "</b><br>"
                        + "Please verify that the following settings are correct:<ul>"
                        + "<li>You have installed a locale SMTP service"
                        + "<li>Your local SMTP service is set to allow relaying for IP 127.0.0.1</li>"
                        + @"<li>The ASPNET account has read/write permissions in mailroot directory (usually 'C:\inetpub\mailroot')</li>"
                        + "</ul>";
                }
            }
     }
    </script>

    Regards,
    Eric
  •  04-26-2010, 12:50 AM 60392 in reply to 60385

    Re: how to get the conents of editor on server side

    hwllo
     
    u have used the code in .aspx page
    where s i need the the value of the editor in .aspx.vb  page
     
    i have a mailing function which is called in the .aspx.vb page
     
    how can  i get the value in .aspx.vb page  so that i can use it in
    Protected Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
     
    if u se it in coe behind ie i n aspx.vb page i get editor1 not defined
    i also tried with the below
     

    <script type="text/javascript">

     

    function getHTML()

    {

     

    var editor1 = document.getElementById('<%=Editor1.ClientID%>');

    document.getElementById("txtmatter").value = editor1.getHTML();

    alert(document.getElementById("txtmatter").value)

    }

    </script>

     
    and in the server side code behind used
    txtmatter.value
    but i get txtmatter is undefined
     
    i also tried the above methd but i get the balnk value
     
  •  04-27-2010, 1:45 PM 60473 in reply to 60392

    Re: how to get the conents of editor on server side

    Dear,
     
    Please save the following content to GetContent.aspx,
     
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="GetContent.aspx.vb" Inherits="test_Default" %>
    <%@ Register assembly="CuteEditor" namespace="CuteEditor" tagprefix="CE" %>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <html>
        <head>
            <title>Test Page </title>    
        </head>
        <body>
            <form id="Form1" runat="server">
                <table cellpadding="15">
                    <tr>
                        <td>
                            <h1>Edit Static Html</h1>        
                            This example demonstrates you can use Cute Editor to edit static html page. Below is an example page that displays a document held in an HTML file on the hard drive. When you submit the form, the document is saved back to the drive. <a href="document.htm"><b>Check the document.htm</b></a>
                            <br />
                            <CE:Editor id="Editor1" AllowPasteHtml="false" runat="server" ></CE:Editor><BR>
                            <asp:Button id="btnUpdate" onclick="Submit" Runat="server" Text="Submit"></asp:Button><br />            
                            <asp:textbox id="textbox1" runat="server" TextMode="MultiLine" Height="250px" Width="750px" Font-Name="Arial"></asp:TextBox>                            
                        
                        </td>
                    </tr>
                </table>            
            </form>
        </body>
    </html>

     
    Save the following content to GetContent.aspx.vb
     

    Partial Class test_Default
        Inherits System.Web.UI.Page
        Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

            If Page.IsPostBack Then
                textbox1.Text = Editor1.Text
            Else
            End If
        End Sub
        Public Sub Submit(ByVal sender As Object, ByVal e As System.EventArgs)
            textbox1.Text = Editor1.Text
        End Sub
    End Class
     
    You can run GetContent.aspx, it works.
     
    Regards,
    Eric
     
     
     
  •  04-28-2010, 2:18 AM 60490 in reply to 60473

    Re: how to get the conents of editor on server side

    hi
     
    i tried the same and all that u told yest
    but not able to get the connetnts
    have sent the sample code with th editor that i have in zipped format
     
    when i add the cuteeditor i page seems to get hanges/slowed down even in designer mode
View as RSS news feed in XML