only My site

Wednesday, March 27, 2013

What’s new for developers in SharePoint 2013


http://technet.microsoft.com/en-us/sharepoint/fp142374.aspx

http://msdn.microsoft.com/en-us/library/jj163091.aspx

Wednesday, March 20, 2013

Master Page : MasterPageFile property & 4 Tokens

In SharePoint, this MasterPageFile property is used differently. It may be or may be not the location of the master page file in SharePoint. In SharePoint MasterPageFile can take four predefined values (called tokens). Based on the token values, SharePoint determines which master page to use for the page (default, custom, site collection, etc). The four tokens fall into two categories: dynamic and static. Static token is used by itself to define the master page location. The two static tokens are described below:
  • Token "~site/MasterPageName.master"
In this token, the ~site refers to site relative URL and MasterPageName.master is the name of the master page. So if you provide the token “~site/masterpages/MyMaster.master” and your site URL is like http://sitecollection/site1 then the master page URL will be http://sitecollection/site1/masterpages/MyMaster.master.
  • Token "~sitecollection/MasterPageName.master"
Here the token ~sitecollection points to the site collection URL. So if your site collection URL is http://sitecolleciton then the master page location will be http://sitecolection/MasterPageName.master.
Dynamic token doesn’t provide the master page location rather it points where to get the master page file location. Dynamic tokens are exact values and you can’t change them like static token. The two dynamic token are described below:
  1. Token "~masterurl/default.master"
When you’ll set the value like Page.MasterPageFile= "~masterurl/default.master", SharePoint will use the master page provided in SPWeb.MasterUrl property. So if you set master page file to this token, you need to ensure that you have provided the master page location to SPWeb.MasterUrl property. FYI, the dynamic token is not changeable and you need to provide exact “~masterurl/default.master”.
  • Token "~masterurl/custom.master"
When you will use this token, then SharePoint will use SPWeb.CustomMasterPageUrl property. So along with setting this token, you also need to set the SPWeb.CustomMasterPageUrl property. FYI, the dynamic token is not changeable and you need to provide exact “~masterurl/default.master”.
 
Souce:Article to change the master page dynamically using HTTPmodules

http://www.codeproject.com/Articles/43377/SharePoint-Dynamically-Change-Master-Page

public class DynamicMasterPageModule : IHttpModule
{


    public void Init(HttpApplication context)
    {
        context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
    }
   

     void context_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        Page page = HttpContext.Current.CurrentHandler as Page;
        if (page != null)
        {
            page.PreInit += new EventHandler(page_PreInit);
        }
    }
   

    void page_PreInit(object sender, EventArgs e)
    {

         if (CurrentUser.UserType == UserType.Admin)
        {
            MasterPageFile = "~/MasterPages/AdminMaster.master";
        }
        else if (CurrentUser.UserType == UserType.NormalAuthenitcated)
        {
            MasterPageFile = "~/MasterPages/NormalAuthenticatedMaster.master";
        }
        else
        {
            MasterPageFile = "~/MasterPages/AnonymouskMaster.master";
        }

    }
}


 

Monday, March 4, 2013