Saving a List Template
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSPsite = new SPSite("http://myserver/site"))
{
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
SPList lstSource = oSPWeb.Lists["SourceList"];
lstSource.SaveAsTemplate("FileName.stp", "Name", "Description", false);
lstSource.Update();
}
}
}); //end elivated privileges
Deleting a List Template
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSPsite = new SPSite("http://myserver/site"))
{
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
SPList objLstTempGallery = oSPWeb.Lists["List Template Gallery"];
foreach (SPListItem objLstItem in objLstTempGallery.Items)
{
if (objLstItem.Title == "DEL_LIST_TEMPLATE_NAME")
{
objLstItem.Delete();
objLstTempGallery.Update();
break;
}
}
}
}
}); //end elivated privileges
No comments:
Post a Comment