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

RadEditor Losing Viewstate Dynamically Created

3 Answers 59 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Mark Wells
Top achievements
Rank 1
Mark Wells asked on 07 Aug 2012, 08:21 PM
I am presently upgraing our Telerik controls and am having a problem with the RadEditor (ASP.NET AJAX) not retaining the viewstate on postback.
 
We add the editor dynamically, so that we have an editor for each language that is enabled in our application. We add the editors in the Page_Init event. We only show on at a time. For example if we English and French enabled then there will be 2 editors on the page, but only one will show to the user. The user can change the language by choosing a value from a dropdown which then postsback to then show the other editor. This has worked fine in the past.

Now though, if the user does not change the language and just enters text into the editor, then the content of the editor showing is blank when the page is submitted. If the user changes the language (and thus does a postback) and then clicks save, the viewstate is retatined.

Any ideas for a workaround, or better yet, an actual fix?

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 10 Aug 2012, 12:48 PM
Hello,

I am not aware of the reported problem.

For some reason the editor content is not submitted when the page is submitted. To fix this, you need to manually save the editor content before the submit. If you are submitting the page using a Submit button, add an OnClientClick property for the Submit button:

<asp:Button ID="btnSaveSign" runat="server" Text="OK" OnClientClick="saveEditorContent()" ...

and add the saveEditorContent() JavaScript function on your page:

<script type="text/javascript">
function saveEditorContent()
{
   $find("RadEditor_ID").saveContent();
}
</script>

If this does not help, please, isolate the problem in a simple runnable project and send it for examination. I will debug it and provide a solution after replicating the issue. Please, also specify which is the version you have upgraded from?

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
Mark Wells
Top achievements
Rank 1
answered on 10 Aug 2012, 07:08 PM
Hi Rumen,

The saveContent() function works well and I am going to go with that. I was doing something similar with saving to a hidden field but your solution is much cleaner.

I found another spot where I had just dropped the editor into the markup and had a similar problem where the view state was getting lost on submit buttons. The submit buttons were outside the update panel that the editor was in. Maybe you guys want to try and recreate the problem in that situation (it happens in IE9 but not compatability mode).
0
Mark Wells
Top achievements
Rank 1
answered on 10 Aug 2012, 07:34 PM
Actually, I take back saying that saveContent() works well. That function strips the <a href> tags out. Back to my original solution........
Tags
Editor
Asked by
Mark Wells
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Mark Wells
Top achievements
Rank 1
Share this question
or