Search code examples
c#asp.netumbracoumbraco6

In Umbraco 6 on an ASP masterpage, how do I get an <a> tag to point to a field's "nice URL" as opposed to ID?


At the moment, I have the following code, and it actually mostly works.

<a href="<umbraco:Item runat="server" Field="heroLinkNode" />">
    <umbraco:Item runat="server" Field="heroLinkText" />
</a>

However, it's creating a URL that looks like mydomain.com/1234 instead of mydomain.com/nice-url-of-page.

P.S. Where would I find documentation for this particular case? My Goolge-foo led me here but it wasn't too useful.


Solution

  • a few answers on the umbraco forum: https://our.umbraco.org/forum/developers/api-questions/38261-Umbraco-6-New-API-How-do-I-get-a-URL

    @using Umbraco.Web
    @{
        var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
    }
    
    @umbracoHelper.NiceUrl(yourId)