Tuesday, October 23, 2007

GUID of ContentTypes using SPContentType

The following code snippet can be used to retrieve the GUID of the Content Types used in SharePoint.

using (SPSite site = new SPSite("http://servername:9000/Pages/Default.aspx"))
{
using (SPWeb web = site.OpenWeb())
{
SPContentTypeCollection contenttypecollection = web.ContentTypes;
foreach (Microsoft.SharePoint.SPContentType contenttype in contenttypecollection)
{
lbContentTypes.Items.Add("Name - " + contenttype.Name + " GUID - " + contenttype.Id);
}
}
}

Tuesday, October 23, 2007

GUID of ContentTypes using SPContentType

The following code snippet can be used to retrieve the GUID of the Content Types used in SharePoint.

using (SPSite site = new SPSite("http://servername:9000/Pages/Default.aspx"))
{
using (SPWeb web = site.OpenWeb())
{
SPContentTypeCollection contenttypecollection = web.ContentTypes;
foreach (Microsoft.SharePoint.SPContentType contenttype in contenttypecollection)
{
lbContentTypes.Items.Add("Name - " + contenttype.Name + " GUID - " + contenttype.Id);
}
}
}