Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to brand a blog post according to our standards, and to do that I have simply created a custom visual web part to take the place of the SharePoint default. What I am wondering is how am I going to extract the body and title of the individual blog posts within this custom one? I can get the list of Posts no problem, but what I need is the actual content.

I am hoping to be able to simply hide the original posts web part and extract the data from it, showing it in the custom one, so that when the blogger creates a new post, it will always show up in this custom web part, too.

share|improve this question
add comment

1 Answer 1

The body and title are accessible through the SPListItem object associated with each post in the list.

I didn't test this, but assuming your list is in the object oList and the body field is "body", the following code should output the Title and Body for all of the posts.

foreach (SPListItem oListItem in oList.Items)
{
    Label1.Text += SPEncode.HtmlEncode(oListItem["Title"]) + " 
       -- " + 
       SPEncode.HtmlEncode(oListItem["Body"]) + "<BR>";
}

Reference

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.