RadEditor not Saving new value (Content) to Database

16 posts, 0 answers
  1. johan moolman
    johan moolman avatar
    1 posts
    Member since:
    Dec 2009

    Posted 22 Dec 2009 Link to this post

    Hi
    This seems to be straight-forward i think. I am populating my editor.Content from a database. Loading the content in my Page Load event. (Which works 100%!). But when I change content in the editor via my browser, the original content from the database get saved. I have read issues similar to mine on the forum, but the solution seems to be only for FF. AS you will see in my ASP.Net Markup, UseSubmitBehavior="false" has been added in any case. I have used the radeditor before (a version before it was not AJAX enabled) with no problems at all ! To reference the editor previously I used it for example editor.html to retrieve the value.
    I am not using UpdatePanels. BTW the page gets posted back to itself, and is suppose to reflect changes made after btnSaveContent_Click.
    Thanks in advance !


    ASP.NET Markup

        <asp:Panel runat="server" ID="pnlContentAdminMode" Visible="false">
            <div>
              <telerik:RadEditor ID="edtContent" runat="server" ContentFilters="None"
                EnableAjaxSkinRendering="False" EnableResize="False"
                Font-Bold="True" Height="100%" Language="" NewLineBr="False"
                Skin="Sunset" Width="100%" ToolsFile="~/Scripts/BasicTools.xml" 
                AutoResizeHeight="True" EditModes="Design, Html" AllowScripts="True" >
                <Content>
                </Content>
              </telerik:RadEditor>
              
              <div style="width: 100%; text-align: center; height: 25px; vertical-align: middle; padding-top: 8px">
                <asp:Button runat="server" ID="btnSaveContent" Text="Save Changes" class="btnWide" onclick="btnSaveContent_Click" UseSubmitBehavior="false" />
              </div>      
            </div>
        </asp:Panel>

    Code Behind
            protected void btnSaveContent_Click(object sender, EventArgs e)
            {
                SqlConnection dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConn"].ConnectionString);
                SqlCommand cmdContent = new SqlCommand();

                cmdContent.Connection = dbConn;
                cmdContent.CommandType = CommandType.StoredProcedure;
                cmdContent.CommandText = "updateContent";

                string currentPage = Request.Url.Segments[1].ToString().ToLower();
                //lblContent.Text = currentPage;

                cmdContent.Parameters.AddWithValue("@Page", currentPage);
                cmdContent.Parameters.AddWithValue("@Content", edtContent.Content);
                cmdContent.Parameters.AddWithValue("@User", Session["LoginUser"].ToString());

                dbConn.Open();
                cmdContent.ExecuteNonQuery();

                cmdContent.Dispose();
                dbConn.Close();
            }
  2. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 22 Dec 2009 Link to this post

    Hi Johan,

    The problem is more likely 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 check, e.g.

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

    In case you are having any difficulty, our suggestion is to implement your scenario using a simple <asp:TextBox> instead of RadEditor. Once you get the textbox to work as needed, all you need to do is change the textbox to RadEditor - and all should be fine.

    In case you are able to implement your scenario with a simple <asp:TextBox>, yet you are facing trouble with the RadEditor, please send us your working project in a support ticket and we will make the change for you.

    You should also see the following live demo on the subject: Save In Database.

    Greetings,
    Rumen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris
    Chris avatar
    40 posts
    Member since:
    Feb 2009

    Posted 04 Jan 2010 Link to this post

    We are running into the same problem using a similar setup. We've checked all our code to make sure it is loading once and not overwriting itself. We actually piped the traffic through a proxy and found that the new content is not being posted. For some reason the old content is being posted back to the server. It used to work with the Q1 version and now it doesn't seem to with Q3.
  5. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 05 Jan 2010 Link to this post

    Hi Chris,

    Do you experience this problem in Firefox only?  If this is the case, please, see the following KB article which provides a solution: RadEditor Content Not Saved After Ajax Update in Firefox.

    In order to fix the problem you will have to set the "submit" button's property UseSubmitBehavior="false", e.g.
    <asp:Button  ID="Save"
    UseSubmitBehavior="false"
    OnClick="Save_Click" runat="server" Text="Save Content" />


    Best regards,
    Rumen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Tom Ray
    Tom Ray avatar
    11 posts
    Member since:
    Oct 2009

    Posted 20 Jun 2010 Link to this post

    We are experiencing the exact same thing in IE 7 and 8.  We populate the content from the database in a maintenance screen when it is not a postback and then save to the database when the user clicks update, but the content is the same as it was on load and did not include the users changes.

    Tom Ray
    BI Solution Builders.
  7. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 21 Jun 2010 Link to this post

    Hi Tom,

    Please, see the following live demos which demonstrates how to save the RadEditor's content in a Database and in External HTML file:
    Save In Database,
    Save in External File
    and
    Datagrid Edit Template.

    On the other hand, your problem is more likely related to overriding the editor content yourself, 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 check, e.g.

    if (!Page.IsPostBack)
    {
        radEditor1.Html = "Some content";
    }

    In case you are having any difficulty, our suggestion is to implement your scenario using a simple <asp:TextBox> instead of RadEditor. Once you get the textbox to work as needed, all you need to do is change the textbox to RadEditor - and all should be fine.

    In case you are able to implement your scenario with a simple <asp:TextBox>, yet you are facing trouble with the RadEditor, please send us your working project in a support ticket and we will make the change for you.

    Best wishes,
    Rumen
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. ian webster
    ian webster avatar
    14 posts
    Member since:
    Jan 2006

    Posted 04 Oct 2011 Link to this post

    For the benefit of anyone having this problem in IE 9....

    I was having the exact same problem in IE9 - a rad editor control resetting it's content when it was in an update panel, I have a if (!IsPostBack) check when setting the rad editor content and the content is not being reset. Moving the editor out of the update panel fixes the reset but means the ajax button doesn't work anyway more.

    I can confirm that the suggestion of adding the UseSubmitBehavior="false" tag to the ajax button resolves the issue for me.
  9. Stefan Plattner
    Stefan Plattner avatar
    4 posts
    Member since:
    Jul 2012

    Posted 04 May 2012 Link to this post

    I'm experiencing the same problem since switching to .NET 4.

    I can't apply the fix using 

    UseSubmitBehavior="false" 

    because I'm using a RadToolbar and RadToolbarButtons (Save).

    Is there a solution for my setup?

    I am using the latest version Q2 2012 of the ASP.NET Ajax Controls. 

  10. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 07 May 2012 Link to this post

    Hello,

    You should execute OnClientButtonClicking="javascript:__doPostBack(this.id,'');return false;" in the onclientclick event of the toolbar buttons as explained in the following KB article: RadEditor Content Not Saved After Ajax Update in Firefox, Google Chrome and Safari.

    Greetings,
    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.
  11. Saritha
    Saritha avatar
    1 posts
    Member since:
    Feb 2013

    Posted 28 Feb 2013 Link to this post



    Hi
    Rad Editor
     Content Not Saved After Ajax Update in Firefox, Google Chrome and Safari, its working in IE.


    Can any one help to to resolve this issue.

    Thanks



  12. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 28 Feb 2013 Link to this post

    Hello,

    Could you please explain your scenario in more details and the problem that you experience so that we can help you?

    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.
  13. Joan
    Joan avatar
    29 posts
    Member since:
    Feb 2013

    Posted 04 Mar 2013 Link to this post

    Hi Telerik Team.
    I also have problem to submit my changes on the DB. I dont inicialize on

    Page_Load nothing.


    This is my code example:

    c# code
    Email
    current = context.GetEmail(ID);

    current.Name = RadComboBoxEmail.Text;

    current.Template = RadEditorEmail.Content;

     context.UpdateEmailTemplate(current);

    aspx

       <telerik:RadAjaxPanel  runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
                    <telerik:RadCodeBlock  runat="server">
                        <telerik:RadComboBox ID="RadComboBoxEmail" runat="server" DataTextField="Name" DataValueField="Id" AppendDataBoundItems="True" AutoPostBack="true" OnSelectedIndexChanged="RadComboBoxEmail_SelectedIndexChanged">
                            <Items>
                                <telerik:RadComboBoxItem Value="0" Text="Select" />
                            </Items>
                        </telerik:RadComboBox>
                    </telerik:RadCodeBlock>
                    <br />
                    <br />
                    <telerik:RadEditor runat="server" ID="RadEditorEmail" Width="100%">
                    </telerik:RadEditor>

                <p></p>
                <telerik:RadCodeBlock  runat="server">
                    <asp:Button ID="ButtonSave" UseSubmitBehavior="false"  runat="server" Text="Submit" OnClick="ButtonSave_Click" />
                </telerik:RadCodeBlock>
                </telerik:RadAjaxPanel>

  14. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 06 Mar 2013 Link to this post

    Hello,

    Does the problem happen if you exclude the editor and the submit button from the <telerik:RadAjaxPanel  runat="server" LoadingPanelID="RadAjaxLoadingPanel1"> panel?

    If you are unable to fix it, is it possible to isolate it in a simple working project which shows the problem and send it for examination via a support ticket?

    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.
  15. Qwicksoft
    Qwicksoft avatar
    10 posts
    Member since:
    Dec 2013

    Posted 24 Jun 2014 Link to this post

    Hi Princy,
             I have Use Rad Editor in X Html.If i edit or design in Rad Editor Control,i will Save the Content of Rad Editor to Data Base,in Var Binary(MAX).and How Can i Retrieve The Same Design from Database to Rad Editor?Like if i Click Edit.Please Help Me.
  16. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 24 Jun 2014 Link to this post

    Hello,

    The Save To Database live example, demonstrates how you can load and save the content to database.

    I suggest following the description and the example code provided to build the desired logic.

    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.

     
  17. Fernando
    Fernando avatar
    6 posts
    Member since:
    Apr 2015

    Posted 03 Jun Link to this post

    I solved this with asp: RequiredFieldValidator set to another field of my form.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017