SharePoint: How to add news listings to the News Area thro’ programmatically
I compiled a sample piece of code snippet to add news listings to the news area.
//Site object
SPSite site = new SPSite("https://karthickmain:9090");
//Get the portal context
PortalContext context = PortalApplication.GetContext(site.ID);
//Get the news area guid
Guid newsGuid = AreaManager.GetSystemAreaGuid(context, SystemArea.News);
//Get the new area
Area newsArea = AreaManager.GetArea(context, newsGuid);
//Get the area listing collection
AreaListingCollection objALC = newsArea.Listings;
//Add the news to the listing
AreaListing objAL = objALC.AddListing("Program100" ,"dd",ListingType.News, "",null);
//Set the the html to display the content
objAL.HtmlBlob = "<b>hello world </b> asdfasdf <b><i>Hello World";
//Set the image file url
objAL.LargeIconUrl ="https://karthickmain/newsitm2.gif" ;
//Set the description
objAL.Description = "hello world";
//Set the url for the news
objAL.URL = site.Url + "/txtlstvw.aspx?LstID=" + objAL.ID;
//Update the list collection
objAL.Update();
Comments
- Anonymous
May 31, 2006
Hi Karthick,
The codes snippets that you provided in you blogs really save my day. Since SPS hasn't documented as other technoloiges, your blogs definetly help the developers across the world.
Thanks a lot. - Anonymous
April 29, 2008
PingBack from http://ezinefrontpageblog.info/karthicks-blog-sharepoint-how-to-add-news-listings-to-the-news-area/