Saving RTE Content

Oct 10, 2009 at 4:31 AM

Hai

Can you please guid me how to save the content of the RTE to a Word file using C#.net

Oct 13, 2009 at 7:33 AM
Edited Oct 13, 2009 at 7:36 AM

Hi Sakthivel,

You can save the RTE Content by using Hidden Field control and little java script. I found this answer before from i-forgot-his-name in this site also (sorry i forgot his name) and i did small modification. 

Here is the sample code.

Controls Needed:

  •     lblMessage (Label)
  •     btnView (Button)
  •     H1 (Hidden Field)

In HTML View:

<script type="text/javascript">

     function doAction()

        {

          //H1 is the ASP HiddenField Control

            var elem = document.getElementById('H1');

            elem.value = richeditor.toHtmlString();                         

        }

</script>

 

<!-- Aside from this tag -->

<cc1:RichTextEditor ID="Rte1" runat="server" />

 <!-- I put Button control to trigger the java script function doAction()  and the codebehind-->

<asp:Button ID="btnView"

            runat="server"

            Text="View"

            onclick="btnView_Click"

            onclientclick="javascript:doAction();"/>

 

 

In Code Behind (C#):

 protected void btnView_Click(object sender, EventArgs e)

    {

        //To put it back the contents in the RTE Control

        this.Rte1.Text = H1.Value;

 

        lblMessage.Text = H1.Value;       

    }

  

I hope It will help you. Courtery of i-forgot-his-name.

Tnx.

  

 

 

           

Oct 27, 2009 at 11:03 PM
Edited Oct 27, 2009 at 11:04 PM

but the formatting of the text would be lost? correct?

 

please look at my issue @

http://rte.codeplex.com/Thread/View.aspx?ThreadId=73280

Jan 13, 2011 at 12:13 AM

Hi guys, I have a question what  object type is "richeditor"? because Im alerting richeditor.toHtmlString() and it says undefined. :S

 

I've just download the control and not sure how to use it.  If you have any link that will help me too.