Wednesday, 6 November 2013

Create Welcome Page in SharePoint 2010 programmatically

Share it Please
Using C# :-

                      using (SPSite site = new SPSite(SPContext.Current.Site.ID))

            {
                using (SPWeb web = site.RootWeb)
                {
                    web.AllowUnsafeUpdates = true;
                    SPFolder rootFolder = web.RootFolder;
                    rootFolder.WelcomePage = "SitePages/pageName.aspx"
                    rootFolder.Update();
                }
            }

Using Power Shell :-

            $SiteUrl = "http://abcd-pc:12121/sites/Samples/"
            Site = Get-SPWeb -identity $SiteUrl
            $RootFolder = $Site.RootFolder;
            $RootFolder.WelcomePage = "SitePages/pageName.aspx";
            $RootFolder.Update();
            $Site.Dispose()

No comments:

Post a Comment

Followers

Follow The Author