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 have created a standard SharePoint Links list, using Managed Client Object Model (for Silverlight). Here's the code:

ClientContext clientContext = new ClientContext(sitePath);
clientContext.ExecuteQueryAsync(OnSucceeded, OnFailed);

ListCreationInformation lci = new ListCreationInformation();
lci.Title = "My Links";
lci.Description = string.Empty;
lci.TemplateType = ListTemplateType.Links;
List list = clientContext.Web.Lists.Add(lci);
clientContext.ExecuteQueryAsync(OnSucceeded, OnFailed);

I want to be able to add items to this list programmatically, but I am stuck. Normally, I'd add a new list item in the following manner:

ListItemCreationInformation lici = new ListItemCreationInformation();
ListItem item = list.AddItem(lici);
item.ParseAndSetFieldValue("Some field name", "Some field value");
item.ParseAndSetFieldValue("Some other field name", "Some other field value"); 
clientContext.ExecuteQueryAsync(OnSucceeded, OnFailed);

The problem is that I don't know which field I should target for the link's URL and Title fields. Help please. Thank you.

share|improve this question
up vote 3 down vote accepted

I found a way. There is a class FieldUrlValue in the Client Ojbect Model for this type of situations. Here's how I implemented it:

ListItemCreationInformation lici = new ListItemCreationInformation(); 
ListItem item = list.AddItem(lici);

FieldUrlValue link = new FieldUrlValue();
link.Url = "http://some-address";
link.Description = "Some Address Title";
item["URL"] = link; 

item.["Some other field name"] = "Some other field value";  
clientContext.ExecuteQueryAsync(OnSucceeded, OnFailed); 

I hope the others will benefit from my find. Cheers!

share|improve this answer

If you go to the settings page of the Links list you will see the names of the field you are after - URL

There is no separate address and tile filed - just enter it as HTML.

<a href="http://someaddress">Some Title</a>
share|improve this answer
Ryan, thank you for helping me out. If I use the line you have suggested, I get the following exception message: [Microsoft.SharePoint.Client.ServerException] = {Microsoft.SharePoint.Client.ServerException: Invalid URL: <a href="">Google</a>. at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.Sha... Do you know perhaps what am I doing wrong? Thanks. – Boris Nov 9 '11 at 10:28
I've solved the problem and posted the solution. – Boris Nov 9 '11 at 14:29

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.