Saturday, August 18, 2012

Setting Culture in ASP.NET

Difference between Culture and UICulture


Culture defines culture dependent objects like currency, date, currency and number formatting.  This can only defined using a specific culture (ex: en-GB not en)

UICulture defines which resources (local and global) will be loaded for this page.  Both neutral and specific cultures.

Setting Culture dynamically at runtime


Culture and UICulture need to be set in the InitializeCulture event


protected override void InitializeCulture()
{
if (Request.Form["DropDownList1"] != null)
{
//can be neutral i.e. en or en-GB
UICulture = Request.Form["DropDownList1"];
//requires a specific culture ex: de-DE
Culture = Request.Form["DropDownList1"];
}
base.InitializeCulture();
}


No comments:

Post a Comment