Text property problem

Jan 31, 2008 at 9:57 AM
I've included the editor in a user control, and it seems to work fine, except for the text property, which only updated if I select the HtmlView tab...
Feb 6, 2008 at 9:13 AM
In case anyone is interested, I found a solution that works for me:

In the OnLoad method of RichTextEditor (or rather, in my inherited class) add the line:

Page.Form.Attributes.Add("onSubmit", "CopyText(); return true;");

This will update the Text property whenever the form is submitted.
Feb 11, 2008 at 8:23 PM
Thanks fromberg for posting your solution. It helped me work out a similar issue I was having. Adding your line of code worked in my test project. In my real app which is inserting the RTE dynamically I had to add some extra code to access the HTML from the RTE. During postback the rte has to be regenerated dynamically and hence loses it's text property values, the HTML Request remains and can be captured. In case anyone is interested:

In the server side event that I wanted to capture the HTML from the RTE I had to use the following line to get the HTML out of the Page Request:
Dim html as string = Me.Page.Request.Form(Me.UniqueID & "$editor")

This only works in combination with the solution fromberg mentioned above. This fix is not exactly elegant, but get's the job done for me.
Aug 25, 2008 at 6:13 PM
This was the code i was looking for. Thanks!
Oct 5, 2008 at 11:20 PM
You're a lifesaver, fromberg.  Thanks!
Oct 23, 2008 at 2:09 AM
I've been trying to apply this solution but not succeeding very well.
I'd like to update my db during postback but even though I can see the rte1.text value during mouse over, it give an error of "source code cannot be found" when I try to use rte1.text in a SQL statement.
I'm using asp.net/c#
so I was using this.Page.Request.Form(this.UniqueID & "$editor")
but not getting good values
any ideas ?
Rich
I'm exasperated

Jan 15, 2009 at 4:22 AM
Edited Jan 15, 2009 at 4:50 AM

<!-- This is the simplest way I know of to update the RTE control ...

Simply add the following attribute to the button that causes the postback

OnClientClick="CopyText(); return true;"

I have included the full basic test page below

-->

<%@ Page Language="VB" ValidateRequest="false" %>

<%@ Register Assembly="RichTextEditor" Namespace="AjaxControls" TagPrefix="codeplex" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub btnPreview_Click(ByVal sender As Object, ByVal e As System.EventArgs)

litPreview.Text = Rte1.Text

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Codeplex Rte Page Test by jiggles100</title>

</head>

<body>

<form id="form1" runat="server">

<br />

<codeplex:RichTextEditor ID="Rte1" runat="server" Theme="Classic"></codeplex:RichTextEditor>

<p>

<asp:LinkButton Font-Bold="true" ID="btnPreview" runat="server" OnClick="btnPreview_Click"

OnClientClick="CopyText(); return true;">Click here to preview</asp:LinkButton>

</p>

<div style="border: 1px dotted dimgray; background-color: #DDFFEE; padding: 20px;

margin: 20px">

<asp:Literal ID="litPreview" runat="server">test</asp:Literal>

</div>

</form>

</body>

</html>