SharePoint and HTML 5 Technical Implementation
Extended Publishing Page
public class ExtendedPublishingPage : PublishingLayoutPage
{
// variable holds whether this page is html 5 or not (xhtml)
public bool IsHTML5Page = false;
/// <summary>
/// In PreInit, get the context of the page which is getting rendered,
/// containing the master page name and set that as the master page.
/// read the column
/// </summary>
/// <param name="e"></param>
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
if ((MSSharePoint.SPContext.Current.FormContext.FormMode == SPControlMode.Display) && (BrowserCheck.IsHTML5CompliantBrowser()))
{
SwitchHTML(true);
}
else
{
SwitchHTML(false);
}
}
public void SwitchHTML(bool ToHTML5)
{
if (ToHTML5)
{
if (!(PublishingUtilities.IsHTML5Master(this.MasterPageFile)))
{
this.MasterPageFile = PublishingUtilities.GetHTML5Master(this.MasterPageFile);
}
this.IsHTML5Page = true;
}
else
{
if (PublishingUtilities.IsHTML5Master(this.MasterPageFile))
{
this.MasterPageFile = PublishingUtilities.GetXHTMLMaster(this.MasterPageFile);
}
this.IsHTML5Page = false;
}
}
}
No comments:
Post a Comment