Skip to content

SharePoint Designer Injecting _Designer Code Error

by on January 4, 2012

SharePoint Designer 2010 has gotten a lot of grief, and with good reason. Much of the functionality is filled with glitches and sloppy. For example, say you are trying to use a custom page property called “BlogUrl” in a page – this will change based on what is selected for each page.

However, when you put in something like the following:

<a href='<SharePoint:ListProperty runat="server" id="ListProperty1" Property="Footer_x003a_BlogUrl"/>’>More ></a>

It works great!

But publish, close, and reopen, and SharePoint Designer returns a garbled mess:

<a href='<SharePoint:ListProperty runat="server" id="ListProperty1" Property="Footer_x003a_BlogUrl" __designer:Preview="&lt;table cellpadding=&quot;4&quot; cellspacing=&quot;0&quot; style=&quot;font: messagebox; color: buttontext; background-color: buttonface; border: solid 1px; border-top-color: buttonhighlight; border-left-color: buttonhighlight; border-bottom-color: buttonshadow; border-right-color: buttonshadow&quot;&gt;
                &lt;tr&gt;&lt;td nowrap&gt;&lt;span style=&quot;font-weight: bold; color: red&quot;&gt;Error Rendering Control&lt;/span&gt; – ListProperty1&lt;/td&gt;&lt;/tr&gt;
                &lt;tr&gt;&lt;td&gt;An unhandled exception has occurred.&lt;br /&gt;Value does not fall within the expected range.&lt;/td&gt;&lt;/tr&gt;
              &lt;/table&gt;" __designer:Values="&lt;P N=’ID’ T=’ListProperty1′ /&gt;&lt;P N=’Property’ T=’Footer_x003a_BlogUrl’ /&gt;&lt;P N=’Page’ ID=’1′ /&gt;&lt;P N=’TemplateControl’ ID=’2′ /&gt;&lt;P N=’AppRelativeTemplateSourceDirectory’ R=’-1′ /&gt;"/>’>More ></a>

Oddly, this only seems to happen with some attributes…

So now what???

There is a workaround, but it is messy and annoying.

Basically, you have to turn the entire thing into a literal and item property soup.

Examples 1: a simple link

<asp:Literal runat="server" text="<a href=&quot;"/>
<SharePoint:ListProperty runat="server" id="ListProperty1" Property="Footer_x003a_BlogUrl"/>
<asp:Literal runat="server" text="&quot;&gt;View Our Blog ></a>"/>

Example 2: a complex image link

<asp:Literal runat="server" text="<a href=&quot;"/>
<SharePoint:ListItemProperty runat="server" id="ListItemProperty31" Property="Footer_x003a_RightImageLink"/>
<asp:Literal runat="server" text="&quot;&gt;"/>
<asp:Literal runat="server" text="<img src=&quot;"/>
<SharePoint:ListItemProperty runat="server" id="ListItemProperty32" Property="Footer_x003a_RightImageUrl"/>
<asp:Literal runat="server" text="&quot; width=’211px’ height=’114px’ title=&quot;"/><SharePoint:ListItemProperty runat="server" id="ListItemProperty33" Property="Footer_x003a_RightImageTooltip"/>
<asp:Literal runat="server" text="&quot; /&gt;</a>"/>

NOTE: This error will continue to occur in <script></script> tags!

Advertisements
Leave a Comment

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: