Showing posts with label Welcome page. Show all posts
Showing posts with label Welcome page. Show all posts

Saturday, February 23, 2013

Set this url as default/Home page of your browser


In this post we are going to set any url as default/Home page of your browser.
Recently one of my friend asked me to do this. So thought of sharing with you guys as well.
Consider we are going to set the http://www.google.co.in as the Default/Home page of the browser.

Add a below anchor tag to your webpage
<A style="CURSOR: hand; font-decoration: underline" href="#" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.google.co.in');">set as your home page</A>

So when user clicks on this button, a popin will appear asking to set google as the home page.
Just click on Ok. That's it, your browser has been updated with the default/Home page as google.com


Hope this helps...


Wednesday, March 7, 2012

Programatically set the welcome page of a sharepoint site MOSS2010

In this post we will see how to change the welcome page of a sharepoint site using object modelling.

Normally for any sharepoint site, the welcome page will be default.aspx. In this post we will set the Home.aspx page(present in pages library) as the welcome page, so that home.aspx will open as soon as user opens the site.

Below is the code snippet::

        /// <summary>
        /// method to add welcome page
        /// </summary>
        /// <param name="publishingWeb"></param>
        /// <param name="oWeb"></param>
        /// <param name="pageName"></param>
        private void CreateWelcomePage(PublishingWeb publishingWeb, string pageName)
        {
            try
            {
                string fullPageUrl = publishingWeb.Url + "/Pages/" + pageName + ".aspx";
                SPFile fileNew = publishingWeb.Web.GetFile(fullPageUrl);
                publishingWeb.DefaultPage = fileNew;
                fileNew.Publish(pageName + ".aspx set as Welcome Page");
                fileNew.Approve(pageName + ".aspx set as Welcome Page");
                publishingWeb.Update();
            }
            catch (Exception ex)
            {
               
            }

        }

Call the above method as below
CreateWelcomePage(myPublishingWebObj,"Home");


Hope this helps...
Next post: Programatically applying master page in sharepoint

Popular Posts