Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Chapter 06: Globalization and Accessibility - MCTS Exam 70-515

RSS
Modified on Mon, Jan 09, 2012, 10:29 AM by Administrator Paths: MCTS Exam 70-515 Categorized as MCTS Exam 70-515

Lesson 1: Configuring Globalization and Localization

Using Local Resource Files

  • Specific to a single page
  • MUST be stored in App_LocalResources folder, which is a subfolder either of the site or of any folder containing web pages.
  • The first available matching resource file from the following list is used: culture-specific, language-specific, default.

Naming Convention

DescriptionNameExampleNotes
DefaultPageName.aspx.resx Orders.aspx.resxUsed when there's no match for the user's language-culture
Language-Specific1PageName.aspx.LanguageID.resxOrders.aspx.es.resx2 
Culture-SpecificPageName.aspx.LanguageID-CultureID.resxOrders.aspx.es-mx.resx3 

1 A list of language and culture codes can be found at http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx.

2 "ES" is the language code for Spanish

3 "ES-MX" is the culture code for a Spanish (Mexico).

Attaching Resources

  • Automatic: Use Tools menu > Generate Local Resource File. This creates the App_LocalResources folder (if neccessary) and the RESX file and adds the meta:resourcekey attributes to the controls. Key string properties (Text, Caption, etc.) are externalized to the file via a Key.Property lookup.
  • Implicitly: Add the meta:resourcekey attribute to any control, and add the Key.Property entries in the RESX file(s) as needed.
  • Miscellaneous Text: Use the asp:Localize control with the meta:resourcekey attribute.
  • Explicitly: Use this example: <asp:Button ... Text="<%$ Resources:, ButtonFindResource1.Text %>" />
  • Explicitly: GetLocalResourceObject("Key.Property")

Using Global Resource Files

  • Naming convention is the same as for local resource files.
  • Stored in App_GlobalResources folder off the root folder.
  • Cannot be used implicitly
  • Can be accessed declaratively (see below).
  • Can be accessed programmatically via Resources.ResourceFileName.Resource syntax.
  • Can also be accessed programmatically via GetGlobalResourceObject("ResourceFileName", "ResourceName")

Example

The following references the WelcomeString resource entry in the SharedLocalizedText resource file.

Declaratively
<asp:Label ... Text="<%$ Resources:SharedLocalizedText, WelcomeString %>" ></asp:Label>

Programmatically
WelcomeLabel.Text = Resources.SharedLocalizedText.WelcomeString;



Lesson 2: Configuring Accessibility



ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2018, Patrick Jasinski.