LoadRtfContent and FormView

5 posts, 0 answers
  1. Edward
    Edward avatar
    83 posts
    Member since:
    Feb 2011

    Posted 11 Aug 2015 Link to this post

    I put a RadEditor inside a Formview, which is inside a RadAjaxPanel.  I use the following to load RTF:

             protected void Unnamed_DataBinding(object sender, EventArgs e)

            {
                var txt = sender as RadEditor;

                txt.LoadRtfContent(@"{\rtf1\ansi\deff0
    {\colortbl;\red0\green0\blue0;\red255\green0\blue0;}
    This line is the default color\line
    \cf2
    This line is red\line
    \cf1
    This line is the default color
    }
    ");
            }

     The issue is the editor is displaying the text with HTML tags instead of formatted text.  I am wondering if this is an issue with the trial version (still waiting for my company to process the purchase) since it adds warning text to the content automatically.

  2. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 13 Aug 2015 Link to this post

    Hi Edward,

    I was not able to reproduce the problem locally. Could you send me a sample page where I can actually see and debug the issue? Once I get it I will be able to advise you further.

    There should be no problem with the trial version. Basically it is the same with the dev one.

    Regards,
    Stanimir
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Edward
    Edward avatar
    83 posts
    Member since:
    Feb 2011

    Posted 13 Aug 2015 Link to this post

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;

    namespace Test
    {
        public partial class Test4 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    var d = new Dictionary<string, string>();
                    d.Add("abc", "def");
                    fv.DataSource = d;
                    fv.DataBind();
                }
            }

            protected void Unnamed_DataBinding(object sender, EventArgs e)
            {
                var txt = sender as RadEditor;

                txt.LoadRtfContent(@"{\rtf1\ansi\deff0
    {\colortbl;\red0\green0\blue0;\red255\green0\blue0;}
    This line is the default color\line
    \cf2
    This line is red\line
    \cf1
    This line is the default color
    }
    ");
            }

            protected void Unnamed_Click(object sender, EventArgs e)
            {
                if (fv.CurrentMode == FormViewMode.ReadOnly)
                    fv.ChangeMode(FormViewMode.Edit);
                else
                    fv.ChangeMode(FormViewMode.ReadOnly);
            }
        }
    }
  5. Edward
    Edward avatar
    83 posts
    Member since:
    Feb 2011

    Posted 13 Aug 2015 Link to this post

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test4.aspx.cs" Inherits="Test.Test4" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <link rel="stylesheet" type="text/css" href="~/Style/general.css" />
        <link rel="stylesheet" type="text/css" href="~/Style/sidemenu.css" />
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
                <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptCombine="false" ScriptMode="Release">
                    <Scripts>
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                        <asp:ScriptReference Path="~/Style/general.js" />
                    </Scripts>
                </telerik:RadScriptManager>
                <div class="container">
                    <div style="margin: 0px; width: 100%;" class="portfolio">
                        <div class="toplogobanner">
                            BANNER HERE
                        </div>
                        <div class="mainlayout">

                            <div class="leftmenu">
                                <div class="card">
                                    Menu here
                                </div>
                            </div>

                            <div class="maincontent">
                                <div class="card">
                                    <asp:Button runat="server" Text="switch" OnClick="Unnamed_Click" />

                                    <asp:FormView runat="server" ID="fv">
                                        <ItemTemplate>
                                            <telerik:RadEditor ID="RadEditor1" runat="server" OnDataBinding="Unnamed_DataBinding" EnableTextareaMode="true" />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <telerik:RadEditor ID="RadEditor1" runat="server" OnDataBinding="Unnamed_DataBinding" EnableTextareaMode="true" />
                                        </EditItemTemplate>
                                    </asp:FormView>

                                </div>
                            </div>
                        </div>


                    </div>
                </div>
                

            </telerik:RadAjaxPanel>
        </form>
    </body>
    </html>

  6. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 14 Aug 2015 Link to this post

    Hello,

    Actually this is expected behavior because you set the EnableTextareaMode to true. In this case the content area of the control is textarea  and when its value is set with html it is rendered as plain text.


    Regards,
    Stanimir
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017