当前位置: 代码迷 >> SharePoint >> 怎么用vs获取到在建站里站点模版的
  详细解决方案

怎么用vs获取到在建站里站点模版的

热度:190   发布时间:2016-05-02 07:31:29.0
如何用vs获取到在建站里站点模版的
在我们建一个网站时,都会有些如:team site,blank site等等这样的模版可选,现在我有个任务,要建一个WEBPART,里面显示一个这些模版的列表,输入标题和URL后,点击按钮新建一个站点,请问如何用程序获得这些模版网站的列表,建站时分别怎么带参数建立所选模版的站点
模版

------解决方案--------------------

using (SPSite site = new SPSite ("http://mosshost/" ))
{
 SPWebTemplateCollection temlates1 = site.GetCustomWebTemplates(1033);

 SPWebTemplateCollection temlates = site.GetWebTemplates(1033);
  .........
}


1033是英文的语言代码,中文好像是2052
------解决方案--------------------
参考一下吧。不知道有没有用。 
http://blog.csdn.net/jason_dct/article/details/8546874
------解决方案--------------------

//Check if sub site exists at given site collection
private static bool isWebExists(SPSite spSite, string webRelativeUrl)
{
    bool returnVal = false;
    using (SPWeb currentWeb = spSite.OpenWeb(webRelativeUrl, true))
    {
        returnVal = currentWeb.Exists;
    }
    return returnVal;
}

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.exists(v=office.12).aspx
  相关解决方案