Last post Sep 20, 2011 05:18 AM by JGriffiths
Sep 19, 2011 09:48 AM|JGriffiths|LINK
I want to set the UICulture to auto. I know that I can do this in the individual page or I can set this globally in the web.config file.
However, my web pages all inherit from a base page (of which I have several) and I want to set this value in one of these base pages so that if affects every page that inherits from this base page, but no others.
Is this possible? If so...how?
Sep 19, 2011 05:46 PM|hans_v|LINK
You need to override the InitializeCulture method in the base page:
Sep 20, 2011 05:18 AM|JGriffiths|LINK
Thanks - I'd worked out that this should be set in the InitializeCulture, what I wasn't sure of was how to actually set it to AUTO.
What I'm doing is this (defensive coding removed for clarity):
protected override void InitializeCulture()
// Load the language from the browser
string uiLang = this.Page.Request.Headers["Accept-Language"];
// Set the UI culture
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(uiLang.Split(",".ToCharArray()));