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

RadEditor not Saving new value (Content) to Database

15 Answers 520 Views
Editor
This is a migrated thread and some comments may be shown as answers.
johan moolman
Top achievements
Rank 1
johan moolman asked on 22 Dec 2009, 07:20 AM
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();
        }

15 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 22 Dec 2009, 09:01 AM
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.
0
Chris
Top achievements
Rank 1
answered on 04 Jan 2010, 08:05 PM
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.
0
Rumen
Telerik team
answered on 05 Jan 2010, 01:10 PM
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.
0
Tom Ray
Top achievements
Rank 1
answered on 20 Jun 2010, 02:23 PM
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.
0
Rumen
Telerik team
answered on 21 Jun 2010, 03:25 PM
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
0
ian webster
Top achievements
Rank 1
answered on 04 Oct 2011, 10:37 AM
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.
0
Stefan Plattner
Top achievements
Rank 1
answered on 04 May 2012, 03:24 PM
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. 

0
Rumen
Telerik team
answered on 07 May 2012, 04:10 PM
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.
0
Saritha
Top achievements
Rank 1
answered on 28 Feb 2013, 09:39 AM



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



0
Rumen
Telerik team
answered on 28 Feb 2013, 11:23 AM
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.
0
Joan
Top achievements
Rank 1
answered on 04 Mar 2013, 11:52 AM
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>

0
Rumen
Telerik team
answered on 06 Mar 2013, 04:32 PM
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.
0
Qwicksoft
Top achievements
Rank 1
answered on 24 Jun 2014, 05:58 AM
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.
0
Ianko
Telerik team
answered on 24 Jun 2014, 06:54 AM
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.

 
0
Fernando
Top achievements
Rank 2
answered on 03 Jun 2016, 06:16 PM
I solved this with asp: RequiredFieldValidator set to another field of my form.
Tags
Editor
Asked by
johan moolman
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Chris
Top achievements
Rank 1
Tom Ray
Top achievements
Rank 1
ian webster
Top achievements
Rank 1
Stefan Plattner
Top achievements
Rank 1
Saritha
Top achievements
Rank 1
Joan
Top achievements
Rank 1
Qwicksoft
Top achievements
Rank 1
Ianko
Telerik team
Fernando
Top achievements
Rank 2
Share this question
or