在我们建一个网站时,都会有些如: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