advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the sample project (~1Mb)
Partners & Affiliates
advertisement
advertisement
Average Rating: 4.8/5 | Rate this item | 5 users have rated this item.
 Print Print
Nine ASP.NET Site Navigation Problem Solutions: Part 1 (cont'd)
#6 Centering Yin & Yang by Centralizing Meta-Data
ASP.NET 2.0's ability to store arbitrary page information centrally can solve a great number of problems. For instance, consider the simplicity of maintaining meta-keywords and meta-descriptions in the Web.sitemap rather than distributed across every page. The new approach makes it simple to insert such metadata in the rendered HTML.
advertisement


   <head>
     <title><%# mstrTitle %></title>
     <meta name="description" content="<%# mstrMetaDescription %>" />
     <meta name="keywords" content="<%# mstrMetaKeywords %>" />
Then simply declare and set a couple of protected properties in the code-behind:

   protected string mstrMetaKeywords = "";
   protected string mstrMetaDescription = "";
   protected string mstrTitle = "";
   
   protected void Page_Load(object sender, EventArgs e) {
     if (SiteMap.CurrentNode != null) {
       if (SiteMap.CurrentNode["metaKeywords"] != null)
         mstrMetaKeywords = SiteMap.CurrentNode["metaKeywords"];
       mstrMetaDescription = SiteMap.CurrentNode.Description;
       mstrTitle = SiteMap.CurrentNode.Title;
     }
     ...
     if (!Page.IsPostBack)
       Page.DataBind();
   }
Don't forget to check whether the CurrentNode property or any custom-defined SiteMapNode attributes are null. Lastly add metaKeywords and description attributes to your Web.sitemap file:

 
Figure 3: Displaying TreeView Navigation: The Maintenance page in the solution accompanying this article contains a TreeView that links to a SiteMapDataSource and acts as a site map.
   <siteMapNode 
     url="~/SiteMap.aspx" 
     title="Site Map" 
     metaKeywords="Site Map" 
     description="The Site Map provides links to every 
        page on the site organized in a logical hierarchy." />
This approach vastly simplifies maintaining page-level metadata used by internal or external search engines. By combining the technique with a Master Page, you may just write your Web administrator out of a job!

#7: Sitemap Simplicity
Adding a functional site map to your site is now as easy as adding a SiteMapDataSource and a TreeView to your Web form, and then setting the Treeview.DataSourceID property to the SiteMapDataSource. To hide the root node just set the SiteMapDataSource.ShowStartingNode Property to false. You can make the TreeView a little prettier by setting the ShowExpandCollapse property to false and ShowLines to true. See Figure 3.

Don't Miss the Next Installment!
This article demonstrated seven problems and their solutions using basic ASP.NET 2.0 site navigation techniques in the context of scenarios that developers are most likely to encounter. The second installment in this article series provides two more problems and solutions, and introduces more advanced techniques, including: hiding unauthorized pages, extending the site map provider model to include dynamic content, and caching dynamic content using ASP.NET 2.0's new SqlCacheDependency class.

Page 4 of 4


advertisement
Lee Richardson is founder and Chief Executive Officer of Automated Architecture, Inc., and is the author of the Blue Ink application and the JAG software development methodology. Lee works as a senior consultant for the Headstrong consulting company, specializing in rapid application development technologies. He has nine years of software development experience, is a Microsoft Certified Solution Developer (MCSD), and a Project Management Professional (PMP).
Previous Page: Solutions 4-5  
Page 1: IntroductionPage 3: Solutions 4-5
Page 2: Solutions 2-3Page 4: Solutions 6-7
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES