Custom Master Page Error

If you are applying custom Master page using the custom feature, you may get the following error when viewing or creating a new site,

Cannot convert type ‘Microsoft.SharePoint.WebControls.ScriptLink’ to ‘System.Web.UI.IAttributeAccessor’

This is because; you are exporting the master page using SharePoint Designer. The master page adds the additional codes; you will be seeing that by open via notepad.

<SharePoint:CssLink runat=”server” __designer:Preview=”&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/_layouts/1033/styles/core.css&quot;/&gt;
” __designer:Values=”&lt;P N=’InDesign’ T=’False’ /&gt;&lt;P N=’ID’ T=’ctl01′ /&gt;&lt;P N=’Page’ ID=’1′ /&gt;&lt;P N=’TemplateControl’ ID=’2′ /&gt;&lt;P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ /&gt;”/>

<SharePoint:Theme runat=”server” __designer:Preview=”” __designer:Values=”&lt;P N=’Name’ R=’-1′ /&gt;&lt;P N=’InDesign’ T=’False’ /&gt;&lt;P N=’ID’ T=’ctl02′ /&gt;&lt;P N=’Page’ ID=’1′ /&gt;&lt;P N=’TemplateControl’ ID=’2′ /&gt;&lt;P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ /&gt;”/>

<SharePoint:ScriptLink language=”javascript” name=”core.js” runat=”server” __designer:Preview=”&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;/_layouts/1033/init.js?rev=ck%2BHdHQ8ABQHif7kr%2Bj7iQ%3D%3D&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;/_layouts/1033/core.js?rev=2zFnRPcm89TszX6NUNqMTw%3D%3D&quot;&gt;&lt;/script&gt;
” __designer:Values=”&lt;P N=’Language’ T=’javascript’ /&gt;&lt;P N=’Name’ T=’core.js’ /&gt;&lt;P N=’InDesign’ T=’False’ /&gt;&lt;P N=’ID’ T=’ctl03′ /&gt;&lt;P N=’Page’ ID=’1′ /&gt;&lt;P N=’TemplateControl’ ID=’2′ /&gt;&lt;P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ /&gt;”/>

<SharePoint:CustomJSUrl runat=”server” __designer:Preview=”” __designer:Values=”&lt;P N=’InDesign’ T=’False’ /&gt;&lt;P N=’ID’ T=’ctl04′ /&gt;&lt;P N=’Page’ ID=’1′ /&gt;&lt;P N=’TemplateControl’ ID=’2′ /&gt;&lt;P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ /&gt;”/>

<SharePoint:SoapDiscoveryLink runat=”server” __designer:Preview=”&lt;link type=&quot;text/xml&quot; rel=&quot;alternate&quot; href=&quot;/_vti_bin/spdisco.aspx&quot; /&gt;” __designer:Values=”&lt;P N=’InDesign’ T=’False’ /&gt;&lt;P N=’ID’ T=’ctl05′ /&gt;&lt;P N=’Page’ ID=’1′ /&gt;&lt;P N=’TemplateControl’ ID=’2′ /&gt;&lt;P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ /&gt;”/>

Following are actual codes for the above lines, when you are open the master page via SPD,

<SharePoint:CssLink runat=”server”/>
<SharePoint:Theme runat=”server”/>
<SharePoint:ScriptLink language=”javascript” name=”core.js” runat=”server”/>
<SharePoint:CustomJSUrl runat=”server”/>
<SharePoint:SoapDiscoveryLink runat=”server”/>

To fix this issue, don’t export the master page file using SPD. Instead just copy the code from SPD to an empty master file.

Shantha Kumar T (MCTS)
[email protected]