Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void CreateNewSite(SPWeb web, string sSiteName,string sSiteTemplate)
- {
- string sSiteUrl = web.Url + "/" + sSiteName;
- if (!SiteExists(sSiteUrl))
- {
- try
- {
- web.AllowUnsafeUpdates = true;
- string url = sSiteName;
- string title = sSiteName;
- string description = sSiteName + " Site Testing";
- string type = System.Configuration.ConfigurationSettings.AppSettings["SiteTemplateId"];
- // Site creation with unique permissions
- SPWebCollection webs = web.Webs;
- SPWeb newWeb = webs.Add(url, title, description, 1033, type, true, false);
- newWeb.Navigation.UseShared = true;
- //Adds to site navigation
- SPNavigation nav = newWeb.ParentWeb.Navigation;
- SPNavigationNode node = new SPNavigationNode(newWeb.Title, newWeb.ServerRelativeUrl);
- node = nav.AddToQuickLaunch(node, SPQuickLaunchHeading.Sites);
- //Adds to top quick link
- SPNavigationNodeCollection topnav = web.Navigation.TopNavigationBar;
- node = topnav.AddAsLast(node);
- // Changing the request access email to current user
- newWeb.RequestAccessEmail = newWeb.CurrentUser.Email;
- // Save changes
- newWeb.Update();
- newWeb.Close();
- // Disposing new web object
- //newWeb.Dispose();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- web.AllowUnsafeUpdates = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement