Friday, February 22, 2013

Get SharePoint list id using SharePoint object model

In this post we will discuss about how we can get the list id of a particular SharePoint list using SharePoint 2010 object model.

Also check previous posts on My Site document libraries improvements in SharePoint 2013, Create a Survey in SharePoint 2010 and  Modify All Items view using SharePoint object model.

Below is the code that will give the list if of a SharePoint list.
using(SPSite site = new SPSite("http://SiteURL"))

using(SPWeb web = site.openweb())
{

    SPList list = web.Lists["List Name"];

    string title = list.ID.ToString();

}

You can check out some SharePoint 2013 articles.