Last post Dec 23, 2010 04:57 AM by soloom
Jun 19, 2007 01:47 PM|slyttle|LINK
I am writing an application that has several forms in it.
Each form has its own local resource for French and English translation for my controls. I set the language and culture programmatically using the following code:
Everything works fine for the main page but when I go to another page using Response.Redirect("page2.aspx") I can't seem to set the culture and it defaults back to en_US again.
I've ensured that both Culture="auto" and UICulture="auto" are removed from the page and I am setting the culture in the same way as I do in the main page (which works). I've even tried saving "newCulture" to my session and pulling it out in the other page
and using that to set my culture .... same result ... I always get the default en-US culture EVEN THOUGH Thread.CurrentThread.CurrentCulture says it is set to fr-FR
Jun 19, 2007 02:54 PM|gridview|LINK
I think you should set CultureIndInfo in PreInit event, try it
and here is the link about
ASP.NET page life cycle :http://msdn.microsoft.com/en-us/library/ms178472.aspx
Jun 19, 2007 03:12 PM|slyttle|LINK
Sorry, I should have stated that I am calling this routine from the Page_PreInit. I am therefor effectively setting the culture from Page_PreInit
I even went so far as to create a brand new form and only put in a label with two resource files (the webform3.aspx.fr-FR.resx and webform3.aspx.resx)
Within this new form I am ensuring that the fr-FR cultureinfo object is being passed into Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture from within the Page_PreInit event and I made certain that there was no automatic culture
of language specified in the page directives .... STILL I am getting data from webform3.aspx.resx instead of webform3.aspx.fr-FR.resx.
The only thing I can think of is that it has something to do with the fact that I am calling webform3 via a Response.Redirect
I'm at a loss here.
Dec 17, 2010 01:10 AM|joel.holder|LINK
Hey did you ever solve this? I have exact same issue now. Switching culture on thread works fine. However, if I introduce a Response.Redirect, I always get en-US.
Anyways, if you know the answer, would appreciate a nudge in the right direction.
Dec 20, 2010 04:20 AM|sandy060583|LINK
Public Class LitwarePage : Inherits Page
Protected Overrides Sub InitializeCulture()
‘*** make sure to call base class implementation
‘*** pull language preference from profile
Dim LanguagePreference As String = _
‘*** set the cultures
If LanguagePreference IsNot Nothing Then
Me.UICulture = LanguagePreference
Me.Culture = LanguagePreference
Partial Class _Default : Inherits LitwarePage
'*** page class definition goes here
Dec 23, 2010 04:57 AM|soloom|LINK
try call base.InitializeCulture() after setting ur new culture
protected void SetLocalization(string strLangCult)
newCulture = new CultureInfo(strLangCult);
Thread.CurrentThread.CurrentCulture = newCulture;
Thread.CurrentThread.CurrentUICulture = newCulture;