asp.net 2.0 master page
-
hello all can anyone tell me how to se up CultureInfo and UICulture from master page(System.Web.UI.MasterPage)? thank u for ur advice
Hi there, Basically, to set the CultureInfo and UICulture properties, you'll have the following options: + Set in the web.config file + Set in the Page directive (the Master directive does not support to set those attributes) + Set in code using the Thread.CurrentThread. So if you want to set the properties in the master page, you may consider using the last option. For more information, you can see the document: http://msdn2.microsoft.com/library/bz9tc508(en-us,vs.80).aspx[^]
-
Hi there, Basically, to set the CultureInfo and UICulture properties, you'll have the following options: + Set in the web.config file + Set in the Page directive (the Master directive does not support to set those attributes) + Set in code using the Thread.CurrentThread. So if you want to set the properties in the master page, you may consider using the last option. For more information, you can see the document: http://msdn2.microsoft.com/library/bz9tc508(en-us,vs.80).aspx[^]
thank u for reply ok i'll describe my situation i have one master page for all aspx pages in my project. this master page has a dropdownlist control(postback is enabled) where users can pick up allowed languages. so i want to set up CultureInfo and UICulture during tha application is running. in the Page u can override some methods like InitializeCulture() to set up CultureInfo and UICulture or in Page_PreInit(), but master page has no access to this methods. only the one way i know is to override the method void Application_AcquireRequestState(Object sender, EventArgs e) in global.acax class in .netframework 1.1 i could use Session to save user language, but framework 2.0 do not have access to Session. so i have to use Cookie or userprofile but it does not look user friendly is any other possibilities to do that in master page?
-
thank u for reply ok i'll describe my situation i have one master page for all aspx pages in my project. this master page has a dropdownlist control(postback is enabled) where users can pick up allowed languages. so i want to set up CultureInfo and UICulture during tha application is running. in the Page u can override some methods like InitializeCulture() to set up CultureInfo and UICulture or in Page_PreInit(), but master page has no access to this methods. only the one way i know is to override the method void Application_AcquireRequestState(Object sender, EventArgs e) in global.acax class in .netframework 1.1 i could use Session to save user language, but framework 2.0 do not have access to Session. so i have to use Cookie or userprofile but it does not look user friendly is any other possibilities to do that in master page?
Hi there, There are a couple of ways come to mind: + Because the language dropdownlist is placed in the master page, so you can place a snippet of code to set the CurrentCulture and CurrentUICulture of the Thread.CurrentThread in the Page_Load of the master page based on the selected language. And you need to remember that the code to display the culture-specific text on the web page should go after the culture-setting code. + You can save the selected culture of the user in the user profile[^], then you can set those properties in the overriden InitializeCulture method of the web page. + In the web page, you can access the selected value from the language dropdownlist in the master page and provide a snippet of code to set the culture info of the current thread. Just some ideas. There is also a good article[^] about the localization on the ASP.NET 2.0.