This is a migrated thread and some comments may be shown as answers.

[Solved] Problem when saving content

12 Answers 333 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Curt asked on 04 Dec 2007, 01:51 PM
On my site I'm using the telerik radeditor to allow the user to create a message and then preview it in the browser by storing it to a database for a temporary amount of time. However when the form is submitted, the value from the editor which is stored in the database is the same value as when the page loads. Therefore the value being stored in the database is blank. Why is this?

12 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 04 Dec 2007, 02:22 PM
Hello Curt,

The case could be that the editor's original value overwrites the one submitted from the browser.

This happens, for example, if you did not put the initial value setting in a if block checking whether the page is postback.

 Here is what you should do in your Page_Load method:
  If Not Page.IsPostBack Then
                ' Set the editor content from database here
  End If

If this is not the reason for the problem, we ask you to open a support ticket and send a sample project including your aspx page with its codebehind. We will review your code and provide a solution.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Curt
Top achievements
Rank 1
answered on 04 Dec 2007, 03:38 PM
Hi,

I thought this might be the case, but Ive already tried putting:

If not page.ispostback then
 ....
End If

In fact the whole Page_Load Sub Routine is now within that if statement and its still storing the original values.
0
Rumen
Telerik team
answered on 04 Dec 2007, 04:13 PM
Hi Curt,

Please, review the following demo example: Save in database and review the following help article: Save in database.
If you are not able to solve the issue, please open a support ticket from your Client.net account and send a sample working project that demonstrates the problem.

I will examine it and try to provide a solution.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
ChrisS
Top achievements
Rank 1
answered on 05 Dec 2007, 06:51 AM

Dear Rumen,

I also have the same problem and for me, it is an issue with including the RADEditor within an update panel and viewing the page within FireFox 2.0.0.11.  If you run the following code:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="ajax1.WebForm1" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
        <asp:UpdatePanel runat="server" ID="updatePanelPageContent">  
            <ContentTemplate> 
                <asp:ScriptManager ID="test" runat="server"></asp:ScriptManager> 
                <% radcontent.Text = RadEditor1.Content()%> 
                <asp:Label runat="server" ID="radcontent"></asp:Label> 
                <telerik:RadEditor ID="RadEditor1" runat="server"></telerik:RadEditor> 
                <asp:Button ID="submit" Text="submit" runat="server" /> 
            </ContentTemplate> 
        </asp:UpdatePanel> 
    </div> 
    </form> 
</body> 
</html> 
 

you will see that the label does not update when you submit the form in FF.  IE is fine.  As a secondary issue, the RADEditor does not display correctly in FF.

Any help with the saving problem would be much appreciated.

Many thanks

0
Rumen
Telerik team
answered on 05 Dec 2007, 07:27 AM
Hello Chris Studman,

If you want to submit form data (like the editor value) with Asp.Net buttons and MS Ajax, you need to set UseSubmitBehavior="false". For Example:

<asp:button runat="server" id="ButtonSave" text="Save" onclick="ButtonSave_Click" CssClass="button" UseSubmitBehavior="false" />

If you do not set this property, non-IE browsers will not be able to send the Ajax request properly. Here is how to modify your code:

<asp:UpdatePanel runat="server" ID="updatePanelPageContent"> 
    <ContentTemplate>
        <% radcontent.Text = RadEditor1.Content;%>
        <asp:Label runat="server" ID="radcontent"></asp:Label>
        <telerik:RadEditor ID="RadEditor1" runat="server"></telerik:RadEditor>
        <asp:Button ID="submit" UseSubmitBehavior="false" Text="submit" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel> 


Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Curt
Top achievements
Rank 1
answered on 05 Dec 2007, 10:24 AM
This seems to have also fixed my problem.

Thanks!
0
ChrisS
Top achievements
Rank 1
answered on 05 Dec 2007, 10:59 AM

Dear Rumen,

Thanks your response.  Unfortunately my application uses an asp:ImageButton instead of asp:Button and there is no UseSubmitBehavior property for an asp:ImageButton.  Can you please tell me what the solution is for the same example but with the following line of code replacing the asp:Button?

<asp:ImageButton ID="cmdPageContentSave" runat="server" AlternateText="Icon : Save" ImageUrl="~/assets/gfx/save.gif" Height="16px" /> 

Many thanks for your help.
0
Rumen
Telerik team
answered on 07 Dec 2007, 03:09 PM
Hello Chris,

MS AJAX takes all INPUT content and puts it together to create the POST request. However the RadEditor's content area is an editable IFRAME and the editor puts its content in hidden field to make it participate in POST request.

However in Mozilla, the editor "learns" about AJAX postback too late when all the POST fields are already processed by MS AJAX. This is the reason for the problem. The solution is to get and set the editor's content when the image button is clicked:

<asp:UpdatePanel runat="server" ID="updatePanelPageContent">
    <ContentTemplate>
        <% radcontent.Text = RadEditor1.Content;%>
        <asp:Label runat="server" ID="radcontent"></asp:Label>
        <script type="text/javascript">       
        function SaveEditorContent()
        {
            var editor = $find("<%=RadEditor1.ClientID %>");
            editor.set_html(editor.get_html());
        }
        </script>

       
        <telerik:RadEditor ID="RadEditor1" runat="server"></telerik:RadEditor>
        <asp:ImageButton       
             OnClientClick="SaveEditorContent()" ID="cmdPageContentSave" runat="server" AlternateText="Icon : Save" ImageUrl="http://www.telerik.com/DEMOS/ASPNET/Editor/Img/productLogo.gif" Height="16px" />
   </ContentTemplate>
</asp:UpdatePanel> 


Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brecht
Top achievements
Rank 1
answered on 17 Jan 2008, 01:58 PM
We're still experiencing this problem with the latest version of the controls. The workaround in the post above this one helps, but we wondered if you are planning to fix this.

Cheers
0
Tervel
Telerik team
answered on 17 Jan 2008, 05:18 PM
Hello Lodewijk,

Unfortunately the problem lies entirely in the MS AJAX framework implementation and cannot be fixed by us for two reasons:
1. The problem is rooted deep in the browser-specific code of the MS AJAX  and the sequence of events that happens when an AJAX request is initiated. As you see this only happens in FireFox/Mozilla, but not in IE

2. The editor has no reliable way of its own to detect that an AJAX request in which the editor itself participates begins. To detect such an event, we would need to copy and duplicate lots of code from the MS AJAX framework. Which, one would think, is OK if it will solve the problem. But it won't (see point 1 above) - the code of the MS AJAX framework itself gets confused in its situation.

This is why, the only workaround known at this point is the workaround provided - and that is to explicitly inform the editor when an AJAX request is about to begin.


Greetings,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rob
Top achievements
Rank 1
answered on 14 May 2008, 03:04 AM
G'Day Folks

I have a form with a RadEditor on it, and a button, the codebehind for the button click event uses the editor content. All was well testing in IE, but I just noticed today that Firefox could not see the content.

This thread helped fix the problem, thanks!

Rob
0
Rumen
Telerik team
answered on 14 May 2008, 12:03 PM
Hi Rob,

I am happy to hear that the provided solution helped you to solve the problem.

I just want to inform you that we made a KB article on the topic, which can be helpful too:

RadEditor Content Not Saved After Ajax Update in Firefox.


Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
Curt
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Curt
Top achievements
Rank 1
ChrisS
Top achievements
Rank 1
Brecht
Top achievements
Rank 1
Tervel
Telerik team
Rob
Top achievements
Rank 1
Share this question
or