Welcome to MSDN Blogs Sign in | Join | Help

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("http://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 ="http://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();

Published Monday, March 27, 2006 10:31 PM by Karthikeyan
Filed under:

Comments

# re: SharePoint: How to add news listings to the News Area thro’ programmatically

Wednesday, May 31, 2006 3:46 PM by Nishand Vasudevan
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.

# Ezines and Web Magaizines &raquo; Karthick&#8217;s Blog : SharePoint: How to add news listings to the News Area &#8230;

Anonymous comments are disabled
 
Page view tracker