SharePoint URL Field

One way to assign value to URL field is by joining the url string and its description e.g. https://akurniaga.wordpress.com, My Blog (Not so nice but it works).

Another way is to use SPFieldURLValue:

To get value from a URL Field:

SPFieldUrlValue urlField = new SPFieldUrlValue(item["MyUrl"].ToString());
string description = urlField.Description;
string url = urlField.Url;

To assign to a URL Field:

SPFieldUrlValue urlField = new SPFieldUrlValue();
urlField.Url = "https://akurniaga.wordpress.com";
urlField.Description = "My Blog";
item["MyUrl"] = urlField;

Simple right? 🙂

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: