public static class LinkItemExtensions
{
public static string ToExternal(this LinkItem item)
{
string externalUrl = item.Href;
PermanentLinkMapStore.TryToMapped(item.Href, out externalUrl);
return externalUrl;
}
}
I'm using the PermanentLinkMapStore following a read of this post.
I've been using it when binding a LinkItemCollection to a ListView like this:
PropertyLinkCollection linksProperty = CurrentPage.ToProperty("Links");
var links = from l in linksProperty.Links
select new
{
Href = l.ToExternal(),
Title = l.Title,
Text = l.Text,
Extension = Path.GetExtension(l.Href)
};
lvLinks.DataSource = links;
lvLinks.DataBind();
No comments:
Post a Comment