Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
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
Thank You Dennis. I appreciate your help.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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.
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.
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.
And you should be able to get the currentNode url by doing something like this.
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.
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
Thank You Dennis. I appreciate your help.
is working on a reply...