Home > escape, internal field name, SharePoint > Encode And Decode SharePoint Internal Field Names

Encode And Decode SharePoint Internal Field Names


Someone who is familiar with SharePoint development will know that SharePoint stores Field names as escaped version
For e.g. If you add a field as “Delivery Method”…Then SharePoint will store it as “Delivery_X0020_Date” where it escapes the [space] as “_X0020_”
Some commonly escaped characters are 
  • [space]      _X0020_
  • –                _X002D_
  • (                _X0028_
  • )                _X0029_
SharePoint encodes these field names so as to use them in xml as attributes. 
So, now there are various occasions when you need to have the un-escaped version of the field. Yes, you guessed it right the answer is by using the System.Xml  namespace

using System.Xml; 

string escapedFieldName = "Delivery_X0020_Method"

// decode escaped field name
string unescapedFieldName = XmlConvert.DecodeName(escapedFieldName);

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: