How to Output the HTML to a String Variable

8 posts, 0 answers
  1. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 10 Mar 2010 Link to this post

    Good Day

    Am using RadControls for ASP.NET Ajax Q2 2008. My markup looks like this

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <telerik:radeditor id="RadEditor1" runat="server" skin="Sunset" EditModes="Design, Preview">
            <Content>
     </Content>
    </telerik:radeditor>

    and my server side where i get what has been typed by a user


    String Body = RadEditor1.Content; 


    and the String Body returns a String is not html.

    What am i doing wrong
  2. Rumen
    Admin
    Rumen avatar
    12988 posts

    Posted 10 Mar 2010 Link to this post

    Hello Vuyiswa,

    I just want to make clear that the Content property of RadEditor returns a string. This string will contain all HTML tags placed in the content area of RadEditor. You can see the tags when you switch to HTML mode.

    You can test the Content property in the following live demos: Save In External File and Save in Database.
    If you experience any problems with them, please explain in more details what the problem is and how to reproduce it.

    Best regards,
    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.
  3. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 11 Mar 2010 Link to this post

    So this means that before i get the full html i have to save it first to a File and retrieve the contents  again ?
  4. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 11 Mar 2010 Link to this post

    The Content property of the RadEditor returns the HTML content of the RadEditor as a string. So it contains all the HTML tags and text that was entered. It doesn't return an HTML file, if that's what you were asking.

    I'm assuming what you were asking is that the content returned doesn't contain HTML tags, is that what you were asking? If so, was anything entered in the RadEditor that would generate an HTML tag to be created (i.e. is there bolded text) or is just plain text that was entered. If only plain text was entered then of course that is what the Content property is going to return, since no tags were needed.
  5. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 12 Mar 2010 Link to this post

    Good Day robertw102

    robertw102 wrote:


    The Content property of the RadEditor returns the HTML content of the RadEditor as a string

    So if the content property returns HTML of Rad as String, that means it should have starting html tag and othere html tags, But mine after using the content property its just like a string as the property Text does.

    robertw102 wrote:


    It doesn't return an HTML file, if that's what you were asking.

    No this came back as a Second option if Radeditor cannot out a full html that i can store in a string , then that means the alternative way to do this is to store the html as a file externally and consume the html inside that file,of which will be cumbersome. I dont want to go that Route in thought Radeditor can output the html that you can see on the html view in the RadEditor.

    robertw102 wrote:
    I'm assuming what you were asking is that the content returned doesn't contain HTML tags


    yes that is exactly my question

    robertw102
    wrote:

    was anything entered in the RadEditor that would generate an HTML tag to be created (i.e. is there bolded text) or is just plain text that was entered.

    Honestly Speaking, i only entered plain text, but because i went to the html view, i wanted the html string displayed in that view to be in my variable. So what you mean is that the html gets generated only if i use the formatting tools in the tool bar like bold etc , then after that it will create an html for me?


    Thanks




  6. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 12 Mar 2010 Link to this post

    The RadEditor does not create an HTML page structure when you call the Content property. Meaning it doesn't surround the content inside of an <html>, <head> or <body> tags. I believe that's what you're asking. Only if the RadEditor was loaded with those tags, would it return them, but otherwise it doesn't return anything like that by default.

    If you want to enclose the content entered inside of the tags I mentioned above, you'll need to enclose the content returned inside of them.

    I hope that helps.
  7. Rumen
    Admin
    Rumen avatar
    12988 posts

    Posted 15 Mar 2010 Link to this post

    Hi guys,

    RadEditor offers the ability to edit and save full HTML page. The following demos could be helpful:

    http://demos.telerik.com/aspnet-ajax/editor/examples/saveinexternalfile/defaultcs.aspx

    and

    http://demos.telerik.com/aspnet-ajax/editor/examples/completehtmlsupport/defaultcs.aspx


    All the best,
    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. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 24 Mar 2010 Link to this post

    Thanks guys its working. I thought automatically the content property will give me the html evne if the toolbar is not used. i see now its fine.

    Thanks
Back to Top