using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SiteMapTest : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
       SiteMapNode current = SiteMap.CurrentNode;
       SiteMapNode root = SiteMap.RootNode;
       foreach (SiteMapNode node in root.ChildNodes)
       {
          string s = node.Title;
       }
       SiteMapNode parent = current.ParentNode;
       if (parent != null)
       {
          foreach (SiteMapNode nodeA in parent.ChildNodes)
          {
             string s = nodeA.Title;
          }
       }

      if (SiteMap.CurrentNode != null)
      {
         lnkHome.NavigateUrl = SiteMap.RootNode.Url;
         if (SiteMap.CurrentNode.PreviousSibling != null)
         {
           lnkPrev.NavigateUrl = SiteMap.CurrentNode.PreviousSibling.Url;
           lnkPrev.Text = "Previous (" + SiteMap.CurrentNode.PreviousSibling.Title + ")";
         }
         else
           lnkPrev.Visible = false;

         if (SiteMap.CurrentNode.NextSibling != null)
         {
           lnkNext.NavigateUrl = SiteMap.CurrentNode.NextSibling.Url;
           lnkNext.Text = "Next (" + SiteMap.CurrentNode.NextSibling.Title + ")";
         }
         else
           lnkNext.Visible = false;

         if (SiteMap.CurrentNode.ParentNode != null)
         {
          
           lnkUp.NavigateUrl = SiteMap.CurrentNode.ParentNode.Url;
           lnkUp.Text = "Up (" + SiteMap.CurrentNode.ParentNode.Title + ")";
         }
         else
          lnkUp.Visible = false;
      }
    }

}
