SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 9 down vote accepted

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.
share|improve this answer
Just a note on this. To get the correct name to use in your code, Edit the list settings, click on the column and use the name as shown in the URL. Example : Field=My%5Fx0020%5Fcolumn . I named the column "My column" – Fox Jul 13 '11 at 7:33
Yes, I do what Fox suggests quite a lot. Note, however, that %5F is the URL encoded _ character. I find a useful reminder of what the different hexidecimal codes for the characters are - letters other than space can be encoded this way, though space is the common one. – Andy Burns Jul 13 '11 at 7:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.