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

RadEditor Iframe losing content across postback

14 Answers 459 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Paul Robertson
Top achievements
Rank 1
Paul Robertson asked on 17 Nov 2011, 11:02 AM
Hello

Could someone help to clarify the expected behaviour of the RadEditor content area after a postback? I have a RadEditor control with an Iframe content area, which is on a page with some other textbox controls that need to be validated server side. When the page is submitted for validation from a LinkButton, the validation occurs OK, but the content area loses its contents. Is this expected default behavior?

I've done some research into this already, and I think I'm right in saying that this isn't due to the known issue of the 2010 release whereby the Iframe shows a similar problem when used with AJAX panels: I'm using the 2009 version, and also, it occurs even if an AJAX partial postback is not used on the page. Instead it seems that there is some sort of ViewState handling issue that I have not set up correctly. So working along these lines, my questions are:

Is it possible/necessary to programmatically enable the viewstate for the IFrame content area? I have the ViewState property set on the radEditor control itself, but it seems this is not working automatically through the validation postback. Perhaps I am supposed to include some manual client side Javascript handling of the iframe contents or the editor viewstate in order to persist the contents of the content area? I haven't managed to find any other forum posts that address this issue, which makes me suspicious that I am missing something obvious. But if there are some posts about this issue, it would be great if someone could point me in the right direction. Presumably I don't need to set an id for the editors iframe, it looks as if this is generated automatically?

Thanks if you can help.



14 Answers, 1 is accepted

Sort by
0
Paul Robertson
Top achievements
Rank 1
answered on 17 Nov 2011, 04:02 PM
Just to add further details that I have since discovered, it appears that the iframe content does get automatically saved to the hidden textarea within the radeditor, it's just that the iframe does not get automatically repopulated with the contents of the hidden text area after the postback. Presumably this should work automatically if the editor control is wired up correctly?

As a possible work around, is there anyway to 'loadcontent' manually with client side code, in the same way that you can call 'saveContent' on the editor control object?

Thanks very much

0
Rumen
Telerik team
answered on 17 Nov 2011, 04:19 PM
Hi Paul,

Please, see the following KB article on the subject: RadEditor Content Not Saved After Ajax Update in Firefox, Google Chrome and Safari.

Best regards,
Rumen
the Telerik team
 
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
 
0
Paul Robertson
Top achievements
Rank 1
answered on 25 Nov 2011, 06:28 PM
Hi

Unfortunately I've already been experimenting with all sorts of ways of trying to initiate the postback, along the lines of the suggestion you include. I have the older version of the RadControls toolkit though, which I believe is not affected by the bug in the link you provide, I'm still on the 2009 version running on NET 2.0 (life's just too short to attempt an upgrade, especially with all the alleged bugs I would apparently be faced with!)

My code always works OK on the first serving of a page, but after a postback, specifically, during a server-side validation, no matter how I try to set the content of the editor, e.g. client side set_html, or server side [radEditorID].Content = ..... the original content never appears back in the content area window, it is always just blank. I don't think I should even have to save and reset the content manually like this, but obviously I had to go along this route, as I couldn't get any sort of ViewState to work for the Editor control either. Is it something to do with the server-side validation? I am using the RadEditor control in Iframe mode, and I have a RadAjaxPanel on the page too (though it is currently disabled in order to try and eliminate another variable).

I'm so disappointed in this problem, it seems like such a basic thing to go wrong. I've been trying to fix this literally for weeks, not exactly what you would call productive!

Thanks a lot.



0
Rumen
Telerik team
answered on 28 Nov 2011, 02:33 PM
Hi Paul,

Is it possible 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 (!Page.IsPostBack)
{
//Set the editor content from database here
}

You can replace RadEditor with an Asp:TextBox and try to reproduce the problem. You should also replace the Content property of RadEditor with the Text property of the textbox control.

If the problem is other, please isolate it in a sample working project and send it for examination via a support ticket. We need to reproduce the problem so that we can debug it and see what is causing it.

Best regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Paul Robertson
Top achievements
Rank 1
answered on 30 Nov 2011, 05:45 PM
Hi

I came to the understanding that this behaviour was due a bug in the control being triggered when it is rendered in Firefox, after moving the radEditor control using client side code to a new location in the DOM tree. I thought it was quite tricky to diagnose, so if it is any use to anybody else, there is another thread which includes a workaround solution here:

http://www.telerik.com/community/forums/aspnet-ajax/editor/radeditor-iframe-content-area-loses-css-styles-after-javascript-move-within-dom.aspx#1896240

Cheers



0
Graham
Top achievements
Rank 1
answered on 04 Aug 2012, 05:16 PM
I'm having very similar problem, with IE.  My RadEditor is in a RadWindow dialog.  It was working fine and then it stopped.  A simple ASP Textbox works fine, as does the RadEditor when I remove the RadAjaxPanel.  If I have the window ajaxified, the contents of the editor post back as blank.  I've played around with various suggested client-side scripts, but no luck.  My editor is NOT being reset anywhere in my code.  I've downloaded and upgraded to the 2012 Q2 release - problem is still there.

Updating this post with the workaround.  It's not pretty, but it works and might help someone else.  Added an 'OnClicking' event to the RadButton, and also added an ASP:Hidden.  'OnClicking' stores the editor's get_html() to a variable and then sets the hidden field's value to this variable.  As I say, not pretty but so long as it works. 

     <telerik:RadButton ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Skin="Vista" Text="Submit" OnClientClicking="Clicking"  ></telerik:RadButton>

     <asp:HiddenField id="hidden_RadEditorNotesContent" runat="server" />

            <script type="text/javascript">
                function Clicking()
                {
                    var editor = $find("<%= RadEditorNotes.ClientID %>");
                    var notes = editor.get_html();
                    var hidden = document.getElementById("hidden_RadEditorNotesContent");
                    hidden.value = notes;
                    // alert("The value of the hidden notes are: " + hidden.value);
                    //  this didn't work
                    // editor.set_html(editor.get_html());
                };
            </script>
        </telerik:RadCodeBlock>
0
Graham
Top achievements
Rank 1
answered on 05 Aug 2012, 12:21 PM
Sorry, still not working - I'm now getting the following error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'TAPE
0
Rumen
Telerik team
answered on 07 Aug 2012, 03:00 PM
Hello,

Could you please open a support ticket from your account and provide a simple working project that demonstrates the problem? I will debug it after reproducing the issue and do my best to provide a solution.

Kind regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Majid
Top achievements
Rank 1
answered on 05 Apr 2013, 10:13 PM
Hi Rumen, 

I'm running into the same issue on IE 8 with the 2012 Q3 release. Has this issue been resolved or is there a work around?

I've a usercontrol that has a RadEditor on it. This user control is used on a page, which is called in the iframe of another page. I've a RadToolbar on the parent page. When I click on a toolbar button, and it does a postback, it seems the RadEditor gets rendered again and it loses any content that the user has entered. 

If I place a RadButton on the page that has the usercontrol, then the RadEditor retains the user entered value correctly. It seems the issue is restricted to the case when the button is on the parent page. 

Any help would be appreciated. 

Thanks
0
Stanimir
Telerik team
answered on 08 Apr 2013, 06:28 AM
Hello Majid,

Since there might be different reasons for this behavior, could you please open a support ticket from your account and provide a simple working project that demonstrates the problem? I will debug it after reproducing the issue and do my best to provide a solution.


Regards,
Stanimir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
margan
Top achievements
Rank 1
answered on 18 Jul 2014, 09:12 AM
Hi, has this issue been resolved?

I'm using Q3 2013 release and I'm losing RadEditor content on postback also.
I had a working user control with RadEditor in RadAjaxPanel. Now when I moved this control to iframe only RadEditor loses its content on postback.

It seems that when I changed RadAjaxPanel to RadXmlHttpPanel it started to work but I would like to know what is the reason.

Regards
0
Ianko
Telerik team
answered on 21 Jul 2014, 07:30 AM
Hi Sebastian,

In this thread many reasons for the content missing on post back behavior has been discussed and I can only assume what exactly is the behavior encountered on your end.

The most commonly encountered issue is due to the usage of button that creates the post back. This matter is explained in this forum thread and possible solutions are provided. Note that this behavior is not a bug, but a browser behavior relate to the button element which does not raise the submit event and teh RadEditor cannot save its content properly to preserve it through post backs.

Also, a common mistake that lead to the same behavior is when the content is being overridden in the code behind.

If you still have issue, please send us a proper support ticked with more details provided, so that we could investigate the exact reason for the encountered issue.

Regards,
Ianko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sampath
Top achievements
Rank 1
answered on 15 Oct 2018, 12:24 PM

RadEditor losing content in IE11 in asp.net. 

<telerik:RadEditor ID="txtAllergenWarning" runat="server" EditModes="Design" ToolbarMode="Default" Width="400px" Height="100px" MaxTextLength="1000" ContentAreaMode="Div" ContentFilters="None" ></telerik:RadEditor>

0
Rumen
Telerik team
answered on 15 Oct 2018, 01:21 PM
Hi Sampath,

Have you tried the proposed solutions at RadEditor Content Not Saved After Ajax Update in Firefox, Google Chrome and Safari? They are applicable for IE11 too.

If yes and the problem still persists, please provide the whole page and its codebehind for examination.

The issue could be also related to overriding the editor content in your Page_Load method. Please note that if you read the content of the editor in an event handler (such as a button event handler) this event handler executes later in the page lifecycle compared to Page_Load. This is why, in case you set the initial content in Page_Load it is mandatory to add a !Page.IsPostBack check, e.g.

if (!Page.IsPostBack)
{
    RadEditor1.Content = "Some content";
}

Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Editor
Asked by
Paul Robertson
Top achievements
Rank 1
Answers by
Paul Robertson
Top achievements
Rank 1
Rumen
Telerik team
Graham
Top achievements
Rank 1
Majid
Top achievements
Rank 1
Stanimir
Telerik team
margan
Top achievements
Rank 1
Ianko
Telerik team
Sampath
Top achievements
Rank 1
Share this question
or