c# - How to get current page title from sitemap file? -


In my master page (.aspx file) I have it & lt; div & gt; Page Title to Display:

  & lt; Div class = "header" & gt; & Lt; H1 & gt; Page title goes here & lt; / H1> & Lt; / Div & gt;  

I have a web sitemap file that contains a few pages details (not all pages in my applications)

What should I do between & Lt; H1 & gt; & Lt; / H1> Allow the master page to dynamically display the page title of the current page and if the current page is not in the Sitemap or the title is not, then enter some default string like "Default Title"

< P>

If you want to be lazy about it and do not care about code in your Aspx file, simply:

  & lt; H1 & gt; & Lt;% = SiteMap.CurrentNode! = Null? SiteMap.CurrentNode.Title: "Not in Sitemap!" % & Gt; & Lt; / H1>  

Comments