Question

I'm running into issues referencing column names in SharePoint Designer 2010 when the names have spaces in them. This is discussed in this blog post.

For example, I've tried using the following code:

<xsl:value-of select="@Primary Phone"/>

In design view, Designer gives this error:

Failed setting processor stylesheet : 0x80004005 : Expected token 'EOF' found 'NAME'. @Primary -->Phone<--

"Primary Phone" is one of the built-in columns of SharePoint 2010. I've seen where it replaces spaces with "Column_x0020_Name" but not sure about how this is being done.

How do you reference a column with a space in it? I'm going to not use spaces from now on for custom columns, but for built-in columns, what do you do? Thanks.

Was it helpful?

Solution

SharePoint indeed converts spaces to _x0020_ for internal names, because this is supposed to represent the url encode %20 (aka space). Because of this reason, you should prevent using spaces in field name (and staticname), as you've mentioned yourself. You can keep spaces in the display name.

In code fragments you can also use:

XmlConvert.EncodeName = converts all the special characters to equivalent _x00xx_
XmlConvert.DecodeName = converts all the _x00xx_ back to the special characters.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top