Sep10

Using SharePoint Hyper Link fields with XSLT

 Categories:

This relates to the Data Form and other web parts that use XSL to render a URL list field (Search Results, Content Query, XML Web Part etc)
 
The URL field is displayed in the create and edit items list pages as 2 fields but is stored as a single string with the url separated from the display string by a comma.
 
To render the hyperlink you should use the following
 

<a href="{substring-before(@Field_x0020_Name, ', ')}">

     <xsl:value-of select="substring-after(@Field_x0020_Name, ', ')"/>

</a>

 

Note: the _x0020_ is how field names that contain spaces are stored.

 

I always try and create my field names abbreviated without spaces and then rename them after they are created which doesn't change the field name (it is a shame the field creation UI doesn't let you specify a new field name and display name separately).

 
 

Links to this post

Welcome to the Hotel...

Trackback from Woody Windischman - The Sanity Point on 25 Oct 2008 12:31

Comments

Leave a comment





CAPTCHA Image Validation