Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Craig Cronin 304 posts 503 karma points
    Jul 05, 2011 @ 01:21
    Craig Cronin
    0

    Get HTML from Property using Umbraco

    I have a page with a richeditor and I need to get at the property's HTML value instead of just text.

     

    Node currentPage = Node.GetCurrent();
    int loopCount = 0;

    for (int nodeCount = currentPage.Children.Count-1; nodeCount > -1; nodeCount--)
    {
    loopCount += 1;
    Node page = currentPage.Children[nodeCount];

    string day = page.CreateDate.ToString("dd");
    string month = page.CreateDate.ToString("MMM");
    string topic = page.GetProperty("blogTopic").Value;
    string comment = page.GetProperty("blogComment").Value;
    string author = page.GetProperty("blogName").Value;

    AddDataToTable(day, month, topic, comment, author, dtAuction);

    if (loopCount == 50) break;

    }

     

    This just gets me the text and not the HTML inside.

     

    Any help would be appreciated.

     

     

  • Craig Cronin 304 posts 503 karma points
    Jul 07, 2011 @ 00:14
    Craig Cronin
    0

    Please, any help with this would be appreciated!!!

  • Richard Soeteman 4047 posts 12900 karma points MVP 2x
    Jul 07, 2011 @ 07:49
    Richard Soeteman
    0

    Hi Craig,

    I assume you get the encoded HTML as text? If so try HttpServerUtility.HtmlDecode. Example can be found on  the MSDN site

    Cheers,

    Richard

  • Craig Cronin 304 posts 503 karma points
    Jul 08, 2011 @ 14:22
    Craig Cronin
    0

    Hi Richard,


    Thanks for the reply.  The problem I'm having is

    page.GetProperty("blogComment").Value;

    blogComment has carriage returns in the text editor but the above line just returns the text regardless of carriage returns.  This result in one big piece of text?

     

    Craig

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jul 08, 2011 @ 14:57
    Tom Fulton
    0

    You can use umbraco.library.ReplaceLineBreaks(page.GetProperty("blogComment").Value) to replace the carriage returns with <br/> tags

  • Craig Cronin 304 posts 503 karma points
    Jul 08, 2011 @ 22:25
    Craig Cronin
    0

    Hi Tom,

    Thanks for the help......I've been acting a little like a fool with this one.  Just taken a fresh look at things and

    comment = comment.Replace(

    "\n","<br />");

    Worked

    Thanks for the help tom.

    Craig

Please Sign in or register to post replies

Write your reply to:

Draft