+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Using RadEditor with a blog post

Using RadEditor with a blog post

5 posts, 1 answered
  1. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    11 Jan 2011
    Link to this post

    Hello,

    We have a simple web form to post blog items to a blog in our website pro grammatically. The web form consists of only three fields e-mail, title and content. The e-mail and title are just the normal text boxes and the content field is a normal text area.

    As suggested in the developer manual the web form works perfectly fine the post items are created in the specified blog. Below is the code that we have been using.

    Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager();

                // get all blogs

                IList listOfAllBlogs = blogManager.GetBlogs();

                if (listOfAllBlogs.Count > 0)

                {

                    // get the the blog by ID

                    Telerik.Blogs.IBlog firstBlog = blogManager.GetBlog(BlogId);

                    // create a blog post by calling the CreateContent method of the

                    // ContentManager class through the BlogManager class

     

                    Telerik.Cms.Engine.IContent postContent = blogManager.Content.CreateContent("text/html");

                   

                    // set the parent of the post item to be selected Blog

                    postContent.ParentID = firstBlog.ID;

                    // save the Content property value and the Title meta key

                    postContent.Content = _txtContent.Text;

                    postContent.SetMetaData("Title", _txtTitle.Text);

                    postContent.SetMetaData("Publication_Date", DateTime.Now);

                    //postContent.SetMetaData("Publication_Date", DateTime.Now.AddYears(2));

                    //save the Content item through the BlogManager

                    blogManager.Content.SaveContent(postContent);}

    But in order to provide better user experience we started implementing the Telerik RadEditor for the content field which was a text area before, so that the users can create links for some of the content they put in.

    <telerik:RadEditor

                            runat="server"

                            ID="_txtContent"

                            ToolsFile="~/Sitefinity/ControlTemplates/Blogs/ToolsFile.xml"

                            EnableEmbeddedSkins="True"

                            Skin="Default"

                            Width="100%"

                            EditModes="Design,Html" TabIndex="7">               

                        <CssFiles>

                            <telerik:EditorCssFile Value="~/Sitefinity/ControlTemplates/Blogs/EditorCssFile.css" />

                        </CssFiles>

                     </telerik:RadEditor>

    The code does create a blog post, but it does not keep the formatting that the user provided for example some links that was created in the content of the form. And we are getting an execption stating that: “Please, use the Content property of RadEditor to set its content. The value of the Text property is generated using the value of the Content property

    Can you please suggest me how I can keep the formatting and also how can I refer the content property of RadEditor in code as I am presently using the IContent interface. Can we still use the IContent interface or do I need to use any other interface.

  2. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    11 Jan 2011
    Link to this post
    Also for some reason the toolbox for the RadEditor does not appear too. when I drop in the RadEditor control.
  3. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    11 Jan 2011
    Link to this post
    A little more insight into the problem: The web form that we have built is a custom user control that has the e-mail, title and comments fields in it. It is not a web page of its own, it is custom user control that we are dropping on a web page. Can we drop in a RadEditor control in to custom user control that we develop, because for some reason we can not see toolbox for the RadEditor in the user control.

    Thank you for all your time and support.
  4. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    12 Jan 2011
    Link to this post
    Can someone please provide me some suggestions for this issue.

    Thank you,
    Kiran.
  5. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Jan 2011
    Link to this post
    Hello kiran,

    In order to preserve the html content generated by the RadEditor you should use the Content property of the editor. For example when you are creating the blog post and assigning the content you should use somethig like:
    blogPost.Content = _txtContent.Content;

    Can you please copy/page the whole markup of your user control so that we can see how you are using the editor in it.

    All the best,
    Radoslav Georgiev
    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
    Answered
Register for webinar
5 posts, 1 answered