sharepoint中创建站点:
Method:
public SPWeb Add( string strWebUrl, string strTitle, string strDescription, uint nLCID, string strWebTemplate, bool useUniquePermissions, bool bConvertIfThere )
Parameters:
- strWebUrl
- Type: System.String
A string that contains the new website URL relative to the root website in the site collection. For example, to create a website at http://MyServer/sites/MySiteCollection/MyNewWebsite, specify MyNewWebsite, or to create a website one level lower at http://MyServer/sites/MySiteCollection/Website/MyNewWebsite, specify Website/MyNewWebsite.
- strTitle
- Type: System.String
A string that contains the title.
- strDescription
- Type: System.String
A string that contains the description.
- nLCID
- Type: System.UInt32
A 32-bit unsigned integer that specifies the locale ID.
- strWebTemplate
- Type: System.String
A string that contains the name of the site definition configuration or site template.
By default, a global site template (GLOBAL#0) is added to all site definitions. You cannot explicitly create a site based on a global site template.
- useUniquePermissions
- Type: System.Boolean
true to create a subsite that does not inherit permissions from another site; otherwise, false .
- bConvertIfThere
- Type: System.Boolean
true to convert an existing folder of the same name to a SharePoint site. false to throw an exception that indicates that a URL path with the specified site name already exists.
Site difinition:
value | Site Definition |
STS#0 | Team Site |
STS#1 | Blank Site |
STS#2 | Document Workspace |
MPS#0 | Basic Meeting Workspace |
MPS#1 | Blank Meeting Workspace |
MPS#2 | Decision Meeting Workspace |
MPS#3 | Social Meeting Workspace |
MPS#4 | Multipage Meeting Workspace |
BLOG#0 | Blog |
SGS#0 | Basic Group Work Site |
SGS#1 | Blank Group Work Site |
WIKI#0 | Wiki |
Example:
/// <summary> /// 在当前网站集中创建子网站 /// </summary> /// <param name="strName">子网站的名称</param> /// <param name="strWebUrl">子网站的url,如“/subSite”,创建完成后的链接就是http://siteName/subSite</param> /// <param name="strType">网站类型,如"Team Site , Blank Site , Wiki Site , Blog"等</param> /// <param name="strDescription">网站描述</param> private void CreateWeb(string strName, string strWebUrl, string strType, string strDescription) { SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = SPContext.Current.Site) { try { site.AllWebs.Add(strWebUrl, strName, strDescription, 1033, strType, false, false); } catch (Exception ex){ throw ex; } } }); }