Please upgrade your web browser now. Internet Explorer 6 is no longer supported.
Zac Smith
SharePoint, WSS and MOSS development.

Tip for naming columns and lists in SharePoint

by Zac Smith 14-Jun-09, 3 Comments
When developing against lists, column names with spaces can be rather annoying. Internally SharePoint encodes spaces with the characters '_x0020_'. This isn't the end of the world but is a bit of a pain when writing code that uses the column names. Over the past few months I have found that I got into the habit of always creating columns without the space, and then renaming them.
 
As an example if I wanted to create a column named 'Account Number' I would first name it 'AccountNumber'. The internal name is set only once and is based on what the column is called when it is created. After the initial creation I can then safely rename the column with the space and still reference it as 'AccountNumber'.
 
I have developed the same habit for naming lists. With lists I think it is even more important to not have spaces as you end up with urls that look like this: http://site/lists/my%20task%20list/allitems.aspx. This is not particularly nice to look at and may even cause problems for some search engines. This is also makes it hard to read the URL and ends up as a bit of an accessiblity negative.
You can use the exact same technique as described for naming columns.

Categories: Accessibility, MOSS, WSS, SharePoint
3 responses so far:
  • Monday, 15 Jun 2009 06:54 by Mike Bunyan
    Any information on reserved names for columns? Like 'title'.
  • Monday, 15 Jun 2009 10:12 by Zac Smith
    Hi Mike You can always change the display name of reserved columns to whatever you like. You can also hide the title column all together. If you do this it will make it hard to access the list items as the title column has the link menu attached to it. To get around this just make sure the 'Edit' column is selected in your views so users can still access list items. Unfortunatly there is no way to move the link menu to another column.
  • Tuesday, 16 Jun 2009 06:28 by Brad Saide
    You could use SharePoint manager to "Create" columns using reserved words... although you'd want a solid business case to go forward with it, and a replica of production to test in (of course, we all have one of those - it's our dev environment). The mechanism preventing you creating these columns is just JaveScript or C# - but the API does support it.

 

Post a Comment:
Name:
URL:
Email:
Comments: