Fredrik Normén's Blog - NSQUARED²
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Microsoft Most Valuable Professional
     .Net Framework - ASP.Net - Architecture - Development
NOTE: This list of posts will only list the 15 latest posts, to see the rest, select from the Archives located in the menu to the left. The RSS will only list the 10 lastest posts.
Enable Localization for the SiteMap feature

Category:  ASP.Net 2.0

I got a question about how to enable localization for the SiteMap feature where the web.sitemap file is used, so I decided to write a very short post about it.

 

First you need to add the enableLocalization attribute to the <sitemap> element and set it to true to enable localization:

 

<?xml version="1.0" encoding="utf-8" ?>

<siteMap enableLocalization="true" xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

 

When this is done you add a web recourse file to your project. The folder App_GloabalResources will be created (If you use the November CTP) and by default a Resource.resx file will be added to the folder (if you don’t change the name of the file). When this is done, you can simply add your resources to the file and then use the $resources: expression on the Title or Description attribute of the <siteMapNode> element within the web.sitemap file to get the resources from the resource file:

 

    <siteMapNode url="default.aspx"  title="$resources: Resource, Home">

        <siteMapNode url="about.aspx" title="$resources: Resource, About"/>

        <siteMapNode url="info.aspx" title="$resources: Resource, Info"/>

    </siteMapNode>

</siteMap>

 

The “Resource” after the $resources: expression within the Title attribute is the name of the resource file you have added the resources to. After the comma, you have the resource key located within the resource file. The XmlSiteMapProvider will get the value of the resource key from the specified resource file.

 

 

Posted: Friday, December 31, 2004 - 00:30 GMT+1    Print     E-mail    Comments (4)
   fredrik.nsquared2.com - 2007