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 954 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 3074 posts 13632 karma points MVP 11x 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 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 25, 2013 @ 17:18
    Jeroen Breuer
    1

    You could also try:

    var currentNode = UmbracoContext.Current.PublishedContentRequest.PublishedContent

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft