Copied to clipboard

Flag this post as spam?

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


  • Kevon K. Hayes 255 posts 281 karma points
    Nov 12, 2010 @ 22:32
    Kevon K. Hayes
    0

    How to obtain parent of a parent via .NET

            private Node _currentNode = Node.GetCurrent();
            protected void Page_Load(object sender, EventArgs e)
            {
                _currentNode = _currentNode.Parent.Parent;
            }

    Content
    --Item1
    ----Item2
    ------Web1

    //THIS RETURNS Object not set to an instance of an object.  I running this on Web1 page, I expect to get a handle of Item1.

    Please advise procedure.

  • Tom Maton 387 posts 660 karma points
    Nov 12, 2010 @ 22:49
    Tom Maton
    0

    Not sure if this is right (haven't tested) but try

    _currentNode.Parent.Parent.Id;

    Thanks

    Tom

  • Sean Mooney 131 posts 158 karma points c-trib
    Nov 12, 2010 @ 22:54
    Sean Mooney
    1

    Tom is close, this should do it:

    private Node _currentNode = Node.GetCurrent();
    
    protected void Page_Load(object sender, EventArgs e)
    {
        _currentNode = New Node(_currentNode.Parent.Parent.Id);
    }
  • Kevon K. Hayes 255 posts 281 karma points
    Nov 12, 2010 @ 23:06
    Kevon K. Hayes
    0

    @ Tom - That would only get me the id which is an int and wouldn't be of the same type ... Node vs. Integer.  Didn't see your post Sean I'm trying that now.

Please Sign in or register to post replies

Write your reply to:

Draft