Master Page code behind should like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MasterPageWithCodeBehind.MasterPageModule
{
public class _starter : MasterPage
{
protected System.Web.UI.HtmlControls.HtmlGenericControl divRibbonContainer;
protected Label Label1;
protected void Page_Load(object sender, EventArgs e)
{
divRibbonContainer.Visible = false;
Label1.Text = "Hello World!";
}
}
}
In the application pages you should have a attribute like this:
Add the following Inherits attribute:
Inherits :
To combine the code-behind file with the masterpage there need to be an attribute added to the masterpage directive.
The following data is needed:
■Namespace of the class & Type/Class name (these need to be seperated by a dot) (MasterPageWithCodeBehind.MasterPageModule._starter)
■Strongname/Assembly in my case was this the same as the projectname (MasterPageWithCodeBehind)
■Version (Version=1.0.0.0)
■Culture (Culture=neutral)
■PublicKeyToken (PublicKeyToken=f8a88530fbc7b81b)In the masterpage navigate to the following:
In our case the Inherits would contain:
MasterPageWithCodeBehind.MasterPageModule._starter, MasterPageWithCodeBehind, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f8a88530fbc7b81b
Deploy your SharePoint 2010 project and load the default site.Your ribbon should be gone and a text like Hello World! should be visible.
Refer the following link for details:
http://rburgundy.wordpress.com/2010/03/10/sharepoint-2010-custom-masterpage-with-code-behind-file-%e2%80%93-part-2/
Vinay Chavadi's Blog on Application Development in SharePoint 2010/2013/2016 & SharePoint Online
Subscribe to:
Post Comments (Atom)
-
There are 3 SPJobLockType available: 1. SPJobLockType.None -- if you set it none, the instance will run in all the available s...
-
Overview: We define disaster recovery as the ability to recover from a situation in which a data center that hosts SharePoint Server beco...
No comments:
Post a Comment