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=”<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/core.css"/>
” __designer:Values=”<P N=’InDesign’ T=’False’ /><P N=’ID’ T=’ctl01′ /><P N=’Page’ ID=’1′ /><P N=’TemplateControl’ ID=’2′ /><P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ />”/>
<SharePoint:Theme runat=”server” __designer:Preview=”” __designer:Values=”<P N=’Name’ R=’-1′ /><P N=’InDesign’ T=’False’ /><P N=’ID’ T=’ctl02′ /><P N=’Page’ ID=’1′ /><P N=’TemplateControl’ ID=’2′ /><P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ />”/>
<SharePoint:ScriptLink language=”javascript” name=”core.js” runat=”server” __designer:Preview=”<script type="text/javascript" language="javascript" src="/_layouts/1033/init.js?rev=ck%2BHdHQ8ABQHif7kr%2Bj7iQ%3D%3D"></script>
<script type="text/javascript" language="javascript" src="/_layouts/1033/core.js?rev=2zFnRPcm89TszX6NUNqMTw%3D%3D"></script>
” __designer:Values=”<P N=’Language’ T=’javascript’ /><P N=’Name’ T=’core.js’ /><P N=’InDesign’ T=’False’ /><P N=’ID’ T=’ctl03′ /><P N=’Page’ ID=’1′ /><P N=’TemplateControl’ ID=’2′ /><P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ />”/>
<SharePoint:CustomJSUrl runat=”server” __designer:Preview=”” __designer:Values=”<P N=’InDesign’ T=’False’ /><P N=’ID’ T=’ctl04′ /><P N=’Page’ ID=’1′ /><P N=’TemplateControl’ ID=’2′ /><P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ />”/>
<SharePoint:SoapDiscoveryLink runat=”server” __designer:Preview=”<link type="text/xml" rel="alternate" href="/_vti_bin/spdisco.aspx" />” __designer:Values=”<P N=’InDesign’ T=’False’ /><P N=’ID’ T=’ctl05′ /><P N=’Page’ ID=’1′ /><P N=’TemplateControl’ ID=’2′ /><P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ />”/>
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]