Passaggio all'ora legale 31 marzo 2024 02:00 03:00 sposta avanti l'orologio di 1 ora (si dorme 1 ora in meno)
Ecco come aggiungere, in SharePoint 2007 (WSS3 - MOSS), un Content Type (SPContentType) esistente sul sito ad una lista o document library.
C#
//using Microsoft.SharePoint;
//add a content type to a list
string listUrl = "http://<servername>/Lists/Links";
using (SPSite site = new SPSite(listUrl))
{
  using (SPWeb web = site.OpenWeb())
  {
    SPList list = web.GetList(listUrl);
    //get content type to add
    SPContentType ctNew = web.AvailableContentTypes["Contact"];
    //search content type in list
    SPContentTypeId ctIdList = list.ContentTypes.BestMatch(ctNew.Id);
    //add a content type if not exists
    if (ctIdList == null || ctIdList.IsChildOf(ctNew.Id) == false)
    {
    list.ContentTypes.Add(ctNew);
    //enable content type in list
    list.ContentTypesEnabled = true;
    //update list
    list.Update();
    }
  }
}
Potrebbe interessarti anche: