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.
E.g.: For
Public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
try
{
SPWeb web = properties.Feature.Parent as SPWeb;
CreateBlogSubsite(web);
}
catch (Exception ex)
{
}
}
private void CreateBlogSubsite(SPWeb site)
{
//useUniquePermissions true to create a subsite that does not inherit permissions from another //site; otherwise, false.
using (SPWeb blog = site.Webs.Add(strWebUrl,strTitle,strDescription,nLCID,
strWebTemplate,useUniquePermissions,bConvertIfThere,false, false))
{
blog.Update();
}
}
No comments:
Post a Comment