Friday, July 24, 2009

Introducing Master Pages in Sharepoint

* Central file controlling the layout and design of the content pages in a sharepoint site
  • Title, logo and description of the site
  • Navigation controls
  • Welcome and Administration
  • Search experience
  • Linking cascading style sheet(CSS) files and script files
  • Web part Manager
  • Contentplaceholders for sharepoint products and technologies

Setting Master pages programatically

  • Execute code to switch to new provisioned Master page
  • Feature Receiver

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb site = Properties.Feature.Parent as SPWeb;
Site.Properties["OriginalMasterPage"] = site.MasterUrl;
site.Properties.Update();
site.MasterUrl="/_catalogs/masterpage/Litware.master";
site.Update();
}

CSS Files

  • CSSLink control loads core.css file
  • Override Styles
  • with an Explicit embedded <style> element
  • programitically setting the AlternateCSSUrl property of the SPWeb
    Public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
    SPWeb site = properties.Feature.parent as SPWeb;
    site.AlternateCSSUrl="/_layouts/LitwareCSS/LitwareCore.css";
    site.Update();
    }

    No comments: