I am using the SiteMapPath for my breadcrumb. Currently it displays the path I took to my current page, but I have a message that displays "You are here: Level1 > Level2 > Level3". The SiteMapPath is placed within my MasterPage. I have pages that will not appear on the .sitemap file and thus the breadcrumb will disappear but the message "You are here: " will not. Is there a way for me to check if a URL exist within the .sitemap file? If URL does not exist, I would like to hide the "You are here" message? Thanks.
EDIT I was able to make my code work. Below is the code:
protected void Page_Load(object sender, EventArgs e)
{
if (SiteMap.Providers["MYSITEMAPPROVIDER"].CurrentNode == null)
{
lblMessage.Visible = false;
}
}
It's easy, have you tried using this:
protected void Page_Load(object sender, EventArgs e)
{
if (SiteMap.CurrentNode == null)
{
this.lblMessage.Visible = false;
}
}
SiteMap contains a static property CurrentNode
I already tested and you can use this approach in a master page, user control or a page