Copied to clipboard

Flag this post as spam?

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


  • Tom 713 posts 952 karma points
    Sep 25, 2013 @ 03:41
    Tom
    0

    v6 Get Current Page in CodeBehind i.e. a user control .cs

    Hi I was just wondering how do you get the current node in a cs file in umbraco like you used to with Node GetCurrent

     

    Cheers,

    Tom

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Sep 25, 2013 @ 16:50
    Jeavon Leopold
    2

    Hi Tom,

    You should extend your class with the UmbracoUserControl then you can access the AssignedContentItem object on the Umbraco Helper

    e.g.

    namespace MyNameSpace
    {
        public class MyControl : UmbracoUserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                var currentId = Umbraco.AssignedContentItem.Id;
            }
        }
    }
    

    Thanks,

    Jeavon

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Sep 25, 2013 @ 17:18
    Jeroen Breuer
    1

    You could also try:

    var currentNode = UmbracoContext.Current.PublishedContentRequest.PublishedContent

    Jeroen

  • 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