I'm trying to retrieve just the url attribute of a link field for an item in a view. The view is just using the item as it's model so just retrieving the link field value, which is producing the following:

 <link linktype="external" url="https://en.wikipedia.org/wiki/Anthocyanin" />

Is there any way other than writing a bunch of parsing code to extract the "https://en.wikipedia.org/wiki/Anthocyanin" from that?

  • 2
    So you need ((LinkField)item.Fields["Link Field Name"]).GetFriendlyUrl()? or I didn't understand the problem?
    – Marek Musielak
    May 21, 2019 at 14:44
  • What does your view code look like today? Can you post a sample? May 21, 2019 at 14:49

1 Answer 1


There is a helper method on LinkField class called GetFriendlyUrl().

Just cast your field to LinkField and execute the method like:

((LinkField)item.Fields["Link Field Name"]).GetFriendlyUrl()
  • Thanks for the reminder, I was able to use the GetFriendlyUrl() to store the url as a variable that I then inserted into the view markup in the appropriate place. May 21, 2019 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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