This article is the continuation of the earlier article Upgrade from SharePoint 2010 to SharePoint 2013
Scenario: Upgrade SharePoint 2010 Solutions to SharePoint 2013 Solutions. In this example we will convert two of my codeplex projects SharePoint 2010 Autocomplete Lookup Field and Export Version History Of SharePoint 2010 List Items to Microsoft Excel built for SharePoint 2010 to SP 2013.
I have Microsoft Visual Studio Premium 2012 and Visual Studio Office Developer Tools installed on my VM. I downloaded the VS 2010 source code of both the projects from the codeplex on my SP 2013 VM.
Converting Export Version History Project to SP 2013:
- Launch an instance of visual studio 2012 and open the Export Version History project.
- Ignore the source control warnings until a warning box asking for upgrading current solution to SP 2013 appears. Click on OK.
Upgrade To SP 2013
- A migration report is generated by the Visual Studio which gives detailed information about the migration.
- SharePoint 2013 uses .Net Framework 4.5 and SharePoint assemblies version 188.8.131.52. Observe that Target Framework in Project properties and assembly versions are automatically updated.
Target Framework and Assembly Versions
- The assembly versions are automatically updated in files like.ascx controls:
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=220.127.116.11, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=18.104.22.168, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=126.96.36.199, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ECBDelegateControl.ascx.cs" Inherits="NY.ExportVersionHistory.ControlTemplates.NY.ExportVersionHistory.ECBDelegateControl" %>
- Now we will see what changes need to be done in code. This step may obviously vary for different SP 2010 solutions. In case of Export Version History, we see that the ribbon buttons are disabled in both the list view and Display form, after upgrading the site from SP 2010 mode to SP 2013.
Disabled Ribbon Buttons
- So, in order to fix the above issues will first look if there are any reference to _layouts folder and change them to use /_layouts/15/. So a code like:
will need to be changed to:
- Similarly any reference to ~/_CONTROLTEMPLATES will need to be changed to ~/_CONTROLTEMPLATES/15
- After applying above changes one can see buttons enabled properly in ribbon of the list.
Export Version History Ribbon Buttons in SP 2013
Converting Auto complete Lookup Field Project to SP 2013:
- Same steps need to be followed as the above project like changing hive and control template references.
- The Auto complete Lookup field is a custom field which inherits from SPFieldLookup. When deployed to SP 2013 it does not render properly in the list view as shown:
Lookup Field Not Rendering
- SharePoint 2013 uses client side rendering to render the fields. The above issue can be resolved by editing the list view webpart and enabling the server side rendering as shown:
- The above method is a manual procedure and hence not the preferred solution since the field may be used at many places. The other way is to override the JSLink property of the custom field.Following code overrides the JSLink property of the custom field and points it to a dummy .JS file which doesn't even exist at the specified path. This simply make sure that the default rendering is not applied on the field. Place this code in the class which inherits from SPFieldLookup class.
//Point to a dummy js file.
private const string JSLinkUrl = "/_layouts/15/NY.Autocomplete.LookupField/JS/dummy.js";
public override string JSLink
if (SPContext.Current.FormContext.FormMode != SPControlMode.Invalid)
base.JSLink = value;
- This is how the list view containing the Autocomplete Lookup field looks after overriding JSLink property.
The SP 2103 versions of both the solutions can be found in codeplex:
Autocomplete in List View