MSDN – Visual Upgrade

02/05/2011: Exploring 70-667 topics based on Keywords in MS Exam Guideline: Visual Upgrade
http://msdn.microsoft.com/en-us/library/gg454789.aspx

Sharepoint provides a new feature called Visual Upgrade to ease the upgrade from Sharepoint 2007. Enable administrator to upgrade sites and content to Sharepoint 2010 without having to worry about coordinating end user’s trainings.

default.master is the default master page of Sharepoint 2007. Layout of the HTML in master.default is dependent on CSS. (a server side control called csslink) core.css. Default.master does not have a DOCTYPE (which forces browser to interpret the page using order set of rules) Sharepoint 2007 site pages typically link to master.default by using a special token instead of a hard-coded path. In Page directive, includes the MasterPageFile attribute, which is assigned the token value of ~masterurl/default.master.
<%@ Page MasterPageFile=“~masterurl/default.master” %>

How visual upgrade works —
Sharepoint 2010 uses new master page new CSS file. In order to make Visual Upgrade possible, Sharepoint 2010 also must carry forward the old master page/css so they can be used in the new environment.
Sharepoint 2007
V3, Sharepoint 2010 v4. Sharepoint 2010’s default provision master page v4.master.

In Sharepoint 2010, application pages can now link to master pages in the master page gallery.
<%@ Page MasterPageFile=”~/_layouts/application.master” %>

minimal.master doesn’t have Site Actions, Top Nav
bar, Quick Launch
etc.

V4.master HAS a DOCTYPE.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#8221;>

v4.master uses DIV tag, instead of table layout.

SPWeb has a MasterUrl property. When you create a new site in Sharepoint 2010, the MasterUrl is initialized to reference the instance of v4.master in the current site. When you update the MasterUrl property of a site, all the site pages and application pages use the same new master page URL. Application page can use DynamicMasterPageFile.

Publishing Site Pages: When swapping master page in a publishing site, you update the CustomMasterURL.

Each Sharepoint site is represented by a SPWeb object. Starting from Sharepoint 2010, each SPWeb carries a new UIVersion property that is tracked in content database. (3 or 4) Another new property in Sharepoint 2010, UIVersionConfigurationEnabled – if True, then Admin has power to move versions back and forward; if False, does not. When you create a new site in Sharepoint 2010, the value is False. When upgrade from Sharepoint 2007 to Sharepoint 2010, the UI version =3, and UIVersionConfigurationEnabled=True.

Updating UIVersion property with Code:

string url = http://intranet.wingtip.com&#8221;;
using (SPSite siteCollection = new SPSite(url)) {
foreach (SPWeb site in siteCollection.AllWebs) {
site.UIVersion = 4;
site.UIVersionConfigurationEnabled = false;
site.Update();
}
}


Updating UIVersion property with Powershell

$site = Get-SPWeb http://intranet.wingtip.com
$site.UIVersion = 4
$site.UIVersionConfigurationEnabled = false
$site.Update()


Managing the Visual Upgrade Process —
After upgrading from 3 to 4, need to make sure that all site pages use ~masterurl/default.master, instead of hardcoding it.

When you switch from 3 to 4, two things change:
(1) Without DOCTYPE (3) à with DOCTYP E(4)
(2) core.css (3) à corev4.css (4)

If there are HTML code that doesn’t work with version 4, you can use a Sharepoint UIVersionContent
to force it to display using version 3:
<Sharepoint:UIVersionedContent ID=myContentIDv3 runat=“server” UIVersion=“3”>

<ContentTemplate>

<p>This content displays only when UIVersion=3.</p>

</ContentTemplate>

</SharePoint:UIVersionedContent>

<Sharepoint:UIVersionedContent ID=myContentIDv4 runat=“server” UIVersion=“4”>

<ContentTemplate>

<p>This content displays only when UIVersion=4.</p>

</ContentTemplate>

</SharePoint:UIVersionedContent>

To point to different CSS files:

<Sharepoint:UIVersionedContent ID=“myLinkIDv3” UIVersion=“3”

runat=“server” >

<ContentTemplate>


<link href=“WingtipStyles.css” rel=“stylesheet” type=“text/css” />

</ContentTemplate>

</SharePoint:UIVersionedContent>

<Sharepoint:UIVersionedContent ID=“myLinkIDv4” UIVersion=“4”

runat=“server” >

<ContentTemplate>


<link href=“WingtipStylesv4.css” rel=“stylesheet” type=“text/css” />

</ContentTemplate>

</SharePoint:UIVersionedContent>

If you use Sharepoint 2010, you could instead insert a CSSLink control, and then use CSSRegistration control to apply the correct cascading style sheet. The CSSregistration control enables you to select either version 3 or 4.

Many Web Part in WSS 3 (Sharepoint 2007) output HTML by simply rendering HTML tags, such as:

protected
override
void RenderContents(HtmlTextWriter writer) {

writer.RenderBeginTag(HtmlTextWriterTag.P);

writer.Write(“Hello World”);

writer.RenderEndTag(); // </p>

}

Solution for switching to Sharepoint 2010: IF….ELSE…. for version 3 and 4:

protected
override
void RenderContents(HtmlTextWriter writer) {


int UIVersion = SPContext.Current.Web.UIVersion;


if (UIVersion == 3) {


// Write HTML for site running under version 3.

}


if (UIVersion == 4) {


// Write HTML for site running under version 4.

}

}

Application Page and Publishing Site Pages, use DynamicMasterPageFile to point to ~masterurl/default.master:

<%@ Page DynamicMasterPageFile=“~masterurl/default.master” %>

 

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: