Copied to clipboard

Flag this post as spam?

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


  • rsuthar 13 posts 72 karma points
    Jul 10, 2014 @ 16:28
    rsuthar
    0

    How to find the Next & Previous Node Url by Current Node ID using C#?

    Hello,

    I am working on one website in which I have Next and Previous button. But I don't know how to get Previous url and next page url from current node id.

    I saw code but it is in Razor, I am working in c#.

    Thank you in advance.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 10, 2014 @ 17:51
    Dennis Aaen
    0

    Hi rsuthar

    I am not a .NET developer, but I will try to help you.

    You should be able to get current node by using this.

    @using umbraco.NodeFactory;
    Node currentNode = Node.GetCurrent()
    

    If you want a specific node by and ID you should be able to use, where you need to change the 1234 to the id of your node.

    Node myNode = new Node(1234);
    

    And you should be able to get the currentNode url by doing something like this.

    string url = currentNode.NiceUrl
    

    Then I think that you can get the previous and next url by doing something like this, but as I said in the beginning I am not a backend developer.

    url.Next();
    url.Previous();
    

    You can find the documentation for working with the node factory her: http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-nodefactory

    Hope this can help you.

    /Dennis

  • rsuthar 13 posts 72 karma points
    Jul 10, 2014 @ 18:39
    rsuthar
    0

    Thank You Dennis. I appreciate your help.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies