DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Loading Resources Programmatically

10.24.2006
| 5350 views |
  • submit to reddit
        // load resources at runtime from resx files

// retrieves value of MyResourceKey from ResourceFile.resx located in App_GlobalResources folder
msg1.Text = (string) HttpContext.GetGlobalResourceObject("ResourceFile", "MyResourceKey");

// retrieves value of Page1Resource.Title key from Page1.resx file located in App_LocalResources folder
// in directory pointed by virtual path /MyFolder/Sample/
msg1.Text = (string) HttpContext.GetLocalResourceObject("/MyFolder/Sample/Page1.resx", "Page1Resource.Title");