Telerik

Log In
Home / Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / Editor / RadEditor Content Not Saved After Ajax Update in Firefox

RadEditor Content Not Saved After Ajax Update in Firefox

Article Info

Rating: 4

Article information

Article relates to

 Telerik.Web.UI 2007.3 1425+

Created by

 Rumen Zhekov

Last modified

 2008/12/02

Last modified by

 Rumen Zhekov


PROBLEM
RadEditor Content Not Saved After Ajax Update in Firefox

DESCRIPTION
In scenarios in which RadEditor and an <asp:ImageButton or an <asp:Button are placed inside a <telerik:RadAjaxPanel or an <asp:UpdatePanel and the editor's content is updated by pressing the <asp:ImageButton or an <asp:Button the editor's content is not populated in Firefox:

Default.aspx
<asp:ScriptManager ID="ScriptManager2" runat="server" /> 
<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server">  
        <asp:Panel ID="Panel1" runat="server">  
            <div>Standard Button:&nbsp;&nbsp;<asp:Button ID="Button2" runat="server" OnClick="btnSave_Click" Text="Save" /></div>  
            <div style="margin-top: 10px;">Image Button:&nbsp;<asp:ImageButton ID="ImageButton3" runat="server" OnClick="btnSave_Click" ImageUrl="http://www.telerik.com/DEMOS/ASPNET/RadControls/Editor/Skins/Default/buttons/save.gif" /></div>  
            <div style="margin-top: 10px;">  
                <telerik:RadEditor ID="RadEditor1" runat="server" EnableViewState="false"></telerik:RadEditor> 
            </div> 
        </asp:Panel> 
</telerik:RadAjaxPanel> 
 
<asp:UpdatePanel id="UpdatePanel2" runat="server">  
        <ContentTemplate> 
        <div>Standard Button:&nbsp;&nbsp;<asp:Button ID="Button3" runat="server" OnClick="btnSave_Click" Text="Save" /></div>  
            <div style="margin-top: 10px;">Image Button:&nbsp;<asp:ImageButton ID="ImageButton4" runat="server" OnClick="btnSave_Click" ImageUrl="http://www.telerik.com/DEMOS/ASPNET/RadControls/Editor/Skins/Default/buttons/save.gif" /></div>  
            <div style="margin-top: 10px;">  
                <telerik:RadEditor ID="RadEditor3" runat="server" EnableViewState="false"></telerik:RadEditor> 
            </div> 
        </ContentTemplate> 
</asp:UpdatePanel> 

Default.aspx
    protected void btnSave_Click(object sender, EventArgs e)  
    {  
        string content = RadEditor1.Content;  
    } 


SOLUTION
The reason is a problem in the MS AJAX implementation under FireFox.
Prometheus controls, such as RadEditor and RadAjax are built on top of MS AJAX and rely on its mechanism to be informed about partial page updates.

Unfortunately in the case of ImageButtons and server buttons, by the time the MS AJAX framework "informs" the editor that a partial update is about to occur, the POST data has already been collected and recorded. The editor does not get a chance to set the updated content properly. The problem exists only in Firefox, but not in Internet Explorer.

In order to fix the problem you will have to set the "submit" button's property UseSubmitBehavior="false", e.g.

<asp:Button UseSubmitBehavior="false" ID="Button1" runat="server" OnClick="btnSave_Click" Text="Save" />

Since the <asp:ImageButton does not offer such an UseSubmitBehavior property, we develop a workaround that tricks the MS AJAX framework, here it is:

<asp:ImageButton OnClientClick="javascript:__doPostBack(this.id,'');return false;"
ID="ImageButton1" runat="server" OnClick="btnSave_Click"
ImageUrl="Save.gif" />

Note the additional OnClientClick that is needed.

If the solution for the ImageButton does not work in some scenarios, then replace the this.id property with this.name and test again.

You can find attached a sample runing project below that demonstrates both solutions.

Comments

  • A , Jun 5, 2008

    In my case server event handler does not called with your code. i've changed onclientclick...'return false' on 'return true' and now it works. besides your code works on my computer too.

Please Sign In to rate this article.

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use
Copyright © 2002-2008 Telerik. All rights reserved.