本文整理汇总了C#中Web.CreateWeb方法的典型用法代码示例。如果您正苦于以下问题:C# Web.CreateWeb方法的具体用法?C# Web.CreateWeb怎么用?C# Web.CreateWeb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web.CreateWeb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSubSite
/// <summary>
/// Actual sub site creation and modification logic. Calls Core component methods to make things work
/// </summary>
/// <param name="hostWeb"></param>
/// <param name="url"></param>
/// <param name="template"></param>
/// <param name="title"></param>
/// <param name="description"></param>
/// <param name="feedType"></param>
/// <param name="yammerGroupName"></param>
/// <returns></returns>
public void CreateSubSite(Web hostWeb, string url, string template,
string title, string description, string feedType, string yammerGroupName)
{
// Create new sub site
Web newWeb = hostWeb.CreateWeb(title, url, description, template, 1033);
// Set theme for the site
newWeb.SetThemeToSubWeb(hostWeb, "Orange");
//Remove the out of the box "NewsFeed" web part
newWeb.DeleteWebPart("SitePages", "Site feed", "home.aspx");
// Let's first get the details on the Yammer network using the access token
WebPartEntity wpYammer;
YammerUser user = YammerUtility.GetYammerUser(ConfigurationManager.AppSettings["YammerAccessToken"]);
// Notice that in general we do not recommend of matching Yammer group for each site to avoid "group pollution" in Yammer
if (feedType == "Group")
{
// Get Yammer Group - Creates if does not exist. Let's create these as public by default.
YammerGroup group =
YammerUtility.CreateYammerGroup(yammerGroupName, false, ConfigurationManager.AppSettings["YammerAccessToken"]);
// Get Yammer web part
wpYammer = YammerUtility.GetYammerGroupDiscussionPart(user.network_name, group.id, false, false);
}
else
{
// Get OpenGrap object for using that as the discussion feed
wpYammer = YammerUtility.GetYammerOpenGraphDiscussionPart(user.network_name, Request["SPHostUrl"] + "/" + txtUrl.Text,
false, false, "SharePoint Site Feed - " + title);
}
// Add Yammer web part to the page
newWeb.AddWebPartToWikiPage("SitePages", wpYammer, "home.aspx", 2, 1, false);
}
示例2: CreateSubSite
/// <summary>
/// Actual sub site creation and modification logic. Calls Core component methods to make things work
/// </summary>
/// <param name="hostWeb"></param>
/// <param name="url"></param>
/// <param name="template"></param>
/// <param name="title"></param>
/// <param name="description"></param>
/// <param name="feedType"></param>
/// <param name="yammerGroupName"></param>
/// <returns></returns>
public void CreateSubSite(Web hostWeb, string url, string template,
string title, string description, string feedType, string yammerGroupName)
{
// Create new sub site
Web newWeb = hostWeb.CreateWeb(title, url, description, template, 1033);
//Remove the out of the box "NewsFeed" web part
newWeb.DeleteWebPart("SitePages", "Site feed", "home.aspx");
// Let's first get the details on the Yammer network using the access token
WebPartEntity wpYammer;
YammerUser user = YammerUtility.GetYammerUser(ConfigurationManager.AppSettings["YammerAccessToken"]);
// Created Yammer web part with needed configuration
wpYammer = CreateYammerWebPart(feedType, user, yammerGroupName, title);
// Add Yammer web part to the page
newWeb.AddWebPartToWikiPage("SitePages", wpYammer, "home.aspx", 2, 1, false);
// Add theme to the site and apply that
ApplyThemeToSite(hostWeb, newWeb);
}