I recently downloaded the trial version Telerik RadControls for ASP.NET AJAX for evaluation, and am having a problem with the RadEditor. I am attempting to have a user edit content via the editor and then save the HTML content to the database for later use in another area of the website. I have tried searching and have come up with nothing, so I figured I would ask here.
Whenever the user clicks to save the content, the HTML content is not saved. Instead the text is saved and all of the "<br>" tags are replaced with "\n". I have looked multiple times and it looks like I'm referencing the HTML correctly so I don't know why I'm not getting the actual HTML content. Below is the code for my .aspx page:
And this is the code-behind which handles the actual insert into the database:
Whenever the user clicks to save the content, the HTML content is not saved. Instead the text is saved and all of the "<br>" tags are replaced with "\n". I have looked multiple times and it looks like I'm referencing the HTML correctly so I don't know why I'm not getting the actual HTML content. Below is the code for my .aspx page:
<telerik:RadEditor ID="RadContentEditor" Runat="server" Width="100%" Height="350px"> <Tools> <telerik:EditorToolGroup Tag="MainToolbar"> <telerik:EditorTool Name="Print" ShortCut="CTRL+P" /> <telerik:EditorTool Name="AjaxSpellCheck" /> <telerik:EditorTool Name="FindAndReplace" ShortCut="CTRL+F" /> <telerik:EditorTool Name="SelectAll" ShortCut="CTRL+A" /> <telerik:EditorTool Name="Cut" /> <telerik:EditorTool Name="Copy" ShortCut="CTRL+C" /> <telerik:EditorTool Name="Paste" ShortCut="CTRL+V" /> <telerik:EditorToolStrip Name="PasteStrip"> </telerik:EditorToolStrip> <telerik:EditorSeparator /> <telerik:EditorSplitButton Name="Undo"> </telerik:EditorSplitButton> <telerik:EditorSplitButton Name="Redo"> </telerik:EditorSplitButton> </telerik:EditorToolGroup>
******More tool groups here**********
</Tools> <Content> </Content> <ImageManager UploadPaths="/BlastImages/" ViewPaths="/BlastImages/" /> <DocumentManager UploadPaths="/BlastDocuments/" ViewPaths="/BlastDocuments/" /> </telerik:RadEditor> <br /> <table id="buttonTable" width="75%" align="center"> <tr> <td style="width:50%; text-align:center;"> <telerik:RadButton ID="saveContentButton" runat="server" ButtonType="LinkButton" OnClick="saveContentButton_OnClick" Text="Update Content"> <Icon PrimaryIconCssClass="rbSave" /> </telerik:RadButton> </td> <td style="width:50%; text-align:center;"> <telerik:RadButton ID="cancelButton" runat="server" ButtonType="LinkButton" OnClick="cancelButton_OnClick" Text="Cancel"> <Icon PrimaryIconCssClass="rbCancel" /> </telerik:RadButton> </td> </tr> </table> <asp:SqlDataSource ID="sectionDS" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnString %>" SelectCommand="SELECT [Content].id, [Content].page_id, [Content].section_name, [Content].html_content FROM [Content] INNER JOIN Pages ON [Content].page_id = Pages.id WHERE [Pages].page_url=@page_url" > <SelectParameters> <asp:SessionParameter Name="page_url" SessionField="page_url" /> </SelectParameters> </asp:SqlDataSource>And this is the code-behind which handles the actual insert into the database:
protected void saveContentButton_OnClick(object sender, EventArgs e) { PageHelper ph = new PageHelper(); try { string section_id = (string)Session[Constants.SESSION_SECTION_ID]; string section_content = RadContentEditor.Content; ph.updateSectionContent(section_id, section_content); Response.Redirect("~/Web/Admin/Content/ManagePageSections.aspx"); } catch (Exception ex) { Response.Redirect("~/Errors/UnhandledException.htm"); } }