Tag Archives: SharePoint Designer

SharePoint Designer Modifies HTML On Save

The “Designer” in SharePoint Designer is used a little too liberally I think, but regardless here are two issues that SharePoint Designer does to your markup when saving the file. As far as I know this issue happens in both the 2007 and 2010 versions. Also, despite looking through all the program’s options, I can’t find one that causes this behavior to turn it off.

Designer Removes Closing HTML Tags

The first is that it removes closing HTML tags. This happens when you use the shorthand to close a SharePoint control. Here is what it looks like when this issue comes up.

<p>
<SharePointWebControls:fieldvalue id="BoxFourContent" FieldName="BoxFourContent" 
     runat="server"/>
</p>

When saving the file (in this case a page layout), SharePoint Designer removes the closing paragraph tag. To change this instead of using the shorthand to self-close the SharePoint control use the longer version.

<p>
<SharePointWebControls:fieldvalue id="BoxFourContent" FieldName="BoxFourContent" 
     runat="server"></SharePointWebControls:fieldvalue>
</p>

Designer Adds a Non-Breaking Space Character

The second issue is SharePoint Designer adding a non-breaking space character when saving. Here is the markup that causes the issue.

<h2>
<SharePointWebControls:fieldvalue id="PageTitle" FieldName="Title" runat="server"/>
</h2>

In this case simply wrap the control in a span, and the issue goes away. Notice I am using a self-closing tag, yet for some reason in this instance (in the very same document) it doesn’t remove the closing HTML tag. Perplexing.

<h2><span>
<SharePointWebControls:fieldvalue id="PageTitle" FieldName="Title" runat="server"/>
</span></h2>

The first rule of a good web design tool: don’t mess with my markup.

Adding Edit Dialog to a Data Form Web Part

Edit Dialog

Edit Dialog

A client asked me to create a roll-up of some document libraries, and I decided to exercise the data form web part. It worked fine until I was asked why he got an open/save dialog and not the standard SharePoint read-only/edit dialog from document libraries as to the right.

After some help from some Twitter folk (@zaijian and @gvaro) it was made evident that there is some JavaScript that surrounds the anchors in the document library.  After comparing AllItems.aspx to my custom page I saw the JavaScript not included. I then added the JavaScript references around my XSL, and sure enough I got the dialog!

I tried to go one step farther and the whole context menu, but I was only able to get portions of us such as the gold hover bar. I know there were some hidden divs the JavaScript used, but alas I had other work to move onto. If anyone has experience with adding the whole context menu I’d be glad to add it here for others.

<a onclick="return DispEx(this,event,'TRUE','FALSE','TRUE','SharePoint.OpenDocuments.3','0','SharePoint.OpenDocuments','','','','110','0','0','0x7fffffffffffffff')" href="{@FileRef}" onfocus="OnLink(this)"><xsl:value-of select="@FileLeafRef" /></a>