SharePoint Designer 2010 inserts "__designer:Preview" and "__designer:Values" attributes upon reopening of Master Pages

Unanswered SharePoint Designer 2010 inserts "__designer:Preview" and "__designer:Values" attributes upon reopening of Master Pages

  • Wednesday, July 14, 2010 12:28 AM
     
     

    I've been facing an issue using SPD 2010 (RTM 14.0.4760.1000, 64-bit against SharePoint Server 2010 RTM) where any time I attempt to add any items (images, css, js, swf, etc.) from a Site Collection's style library to a custom Master Page using the following style:

    <asp:Literal runat='server' Text='<%$SPUrl:~sitecollection/Style Library/path/file.ext %>

    When this snippet is first added to the Master Page everything works correctly and is sent to the browser as expected. The issue arises when SPD is closed. After reopening SPD and opening the Master Page, any place where the $SPUrl:~sitecollection... snippet is used, the parent tag adds (malformed) "__designer:Preview" and "__designer:Values" attributes describing the file which when saved back cause pages that use the Master page in question to fail.

     

    Perhaps this is a bit unclear so I've come up with some reproducible steps:

    1) Open a Master Page in SPD2010 (e.g. intranet.master)

    2) Reference an image (e.g. intranet.gif) that has been added to Style Library using img tag as follows:

        <img src="<asp:Literal runat='server' Text='<%$SPUrl:~sitecollection/Style Library/images/intranet.gif%>' />

    3) Save Master Page (intranet.master), confirm that the image appears on pages using the Master Page in a browser as expected.

    4) Close SPD2010.

    5) Reopen SPD2010 and reopen the Master Page (intranet.master)

    6) Note that the line we had previously added in #2 now appears as follows:

    <img src="<asp:Literal runat='server' Text='<%$SPUrl:~sitecollection/Style Library/images/intranet.gif%>' __designer:Preview="/sites/intranet/Style Library/images/intranet.gif" __designer:Values="&lt;P N='Text' Bound='True' T='SPUrl:~sitecollection/Style Library/images/intranet.gif' /&gt;&lt;P N='ID' T='ctl34' /&gt;&lt;P N='Page' ID='1' /&gt;&lt;P N='TemplateControl' ID='2' /&gt;&lt;P N='AppRelativeTemplateSourceDirectory' R='-1' /&gt;"/>

    7) If the Master Page is saved back to the Server with the malformed "__designer:Preview" and "__designer:Values" attributes that were added, the page will then return with an error along the lines of the following:

    Error

    '"<asp:Literal' is not a valid virtual path.

    8) The Master Page can be made functional again by removing the "__designer:Preview" and "__designer:Values" attributes from all instances but this is incredibly burdensome as it has to be done for every affected tag, every time SPD is closed and reopened.

     

    I see a similar post on the pre-2010 board regarding this here:

    http://social.msdn.microsoft.com/Forums/en-US/sharepointcustomization/thread/b1f9cbe2-1862-47dc-98e5-2c57328130e8

    but it is unclear if this was ever resolved and what version of SPD they are using.

     

    So my questions are:

    1) Is there any way to stop the automatic insertion of these attributes by SPD?

    2) Is there a better way/syntax to be inserting the full path name of style library files that works regardless of file type and is embeddable within other HTML tags?

    3) Is this expected behavior? / If not, should I be opening a case through my company's Prem account?

All Replies

  • Thursday, July 15, 2010 7:59 AM
    Moderator
     
     

     

    In the contoso IW demo VM, I open the http://intranet/SitePages/Home.aspx in SharePoint Designer 2010 and paste in the following line into the page,and change the URL to the gif file. However, it does not work, kind of syntax error. I noticed that the number of ‘<’ does not equal the number of ‘>’. Could you please post the exact code that work for you?

     

    <img src="<asp:Literal runat='server' Text='<%$SPUrl:~sitecollection/Style Library/images/intranet.gif%>' />

  • Wednesday, January 12, 2011 6:08 PM
     
      Has Code

    GuYuming.  The error is easy to reproduce.

    Pick a page.  I'm using the master page default.master in this example because it provides an easy-to-describe scenario.

    default.master has a reference to core.js within its first page of code.  Duplicate this line exactly and then wrap one of the lines in a COMMENT using the tags "<!--" and "-->".

    For clarity's sake, the line which read:

    	<SharePoint:ScriptLink language="javascript" name="core.js" defer="true" runat="server"/>
    
    

    is now 2 lines which read:

    	<!-- <SharePoint:ScriptLink language="javascript" name="core.js" defer="true" runat="server"/> -->
    	<SharePoint:ScriptLink language="javascript" name="core.js" defer="true" runat="server"/>
    
    

    No problem, right?  Wrong.  Save the file and reopen it and it looks like this:

    	<!-- <SharePoint:ScriptLink language="javascript" name="core.js" defer="true" runat="server" __designer:Preview="&lt;script type=&quot;text/javascript&quot;&gt;
    // &lt;![CDATA[
    document.write('&lt;script type=&quot;text/javascript&quot; src=&quot;/_layouts/1033/init.js?rev=BJDmyeIV5jS04CPkRq4Ldg%3D%3D&quot;&gt;&lt;/' + 'script&gt;');
    // ]]&gt;
    &lt;/script&gt;
    " __designer:Values="&lt;P N='Language' T='javascript' /&gt;&lt;P N='Name' T='core.js' /&gt;&lt;P N='Defer' T='True' /&gt;&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:ScriptLink language="javascript" name="core.js" defer="true" runat="server"/>
    

    WTF?!?!?  This is just one simple example of how to reproduce this problem. 

    When developing master pages I would like to be able to comment-out code and then LATER remove the comment tags AND ACTUALLY HAVE THE SAME SOURCE CODE as I did before commenting.

    The original master pages DID NOT require any of this 'introduced' __designer markup to function in the first place, so WHY IS IT GETTING ADDED and BREAKING MY CODE when I make these minor changes?

    If you look at the OOTB source for default.master or v4.master etc., they DO NOT have any of this markup (i.e. '__designer').  The tool you have provided for us (SP Designer) is working against my efforts.  This is extremely frustrating.


    Mark
  • Wednesday, June 01, 2011 12:50 AM
     
     

    I've detailed a work around/fix to this problem here

  • Saturday, June 02, 2012 3:20 AM
     
     
    I wrote article talk about this problem and its reasons here

    Tarek Yehia