Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lars 66 posts 136 karma points
    Sep 17, 2015 @ 07:38
    Lars
    0

    Razor: Getting the url from a node ID in razor (view)

    Hi. I have a simple question. I want to make a link from one Umbraco page to another. If the node id is, say "1234", how do I write this link in a view? //Lars

  • Stefano Beretta 102 posts 247 karma points
    Sep 17, 2015 @ 07:54
    Stefano Beretta
    0

    Hi Lars!

    I always use

        @{
          var url =  Umbraco.TypedContent(1234).Url
        }
    <a href="@url">link</a>
    

    Br

    Stefano

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 17, 2015 @ 07:57
    Dennis Aaen
    0

    Hi Lars,

    You can use the .NiceUrl helper method. So you can do something like this

    <a href="@Umbraco.NiceUrl(1234)">My link</a>
    

    You can find the documentation of the .NiceUrl here https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/ and there is also one that includes the domain.

    Just search for NiceUrl on the page.

    Hope this helps,

    /Dennis

  • Lars 66 posts 136 karma points
    Sep 17, 2015 @ 08:04
    Lars
    0

    Thank you both for a fine and quick answer. I tried the niceurl and it works. Misson completed :-)

    //Lars

Please Sign in or register to post replies

Write your reply to:

Draft