<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>FAQ - Frequently Asked Questions</title><link>http://forums.asp.net/13.aspx</link><description>Your question has probably already been answered. Look here for some great answers!</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/3345033.aspx</link><pubDate>Thu, 13 Aug 2009 05:13:01 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3345033</guid><dc:creator>suneel.gmbs</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3345033.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=3345033</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;I am suneel, i did the same thing that you explained but this doesn&amp;#39;t change my labels and other controls in the content page of the web pages which are inherited from the base page.&lt;/p&gt;&lt;p&gt;Can you tell me how to change these controls so that whole of my web page should look in that specific language.&lt;/p&gt;&lt;p&gt;I need this immediately.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thanks in Advance&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/2678360.aspx</link><pubDate>Mon, 13 Oct 2008 06:06:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2678360</guid><dc:creator>kaleem.khan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2678360.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=2678360</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;As the rap song goes: â€œThereâ€™s no champagne in the champagne
room...â€, there is no page in MasterPage. It derives from
UserControl. As such it does not support the InitializeCulture() method
for us to override as described in this post. Newbies love master
pages, even though half the time they do not understand them, so here
is a solution, compounding the misuse, but here it goes.&lt;br /&gt;
Declare a dropdown as usual in the master page. Instead of overriding
the InitializeCulture() place the same code in the
Application_BeginRequest event handler in the global.asax. It is very
similar to InitializeCulture() in the sense that it occurs early and no
controls are ready yet. We have a little problem though, now the
control is declared in a template and its name and id attributes
rendered differently. We can&amp;#39;t use the control id and cheat like in the
other post any more. We cant use the Control.UniqueID property either,
remember no controls yet. So now what?&lt;br /&gt;
Another collection like the form variables collection that is also not
originally server collection is the cookies collection. I use the
cookie but it can be any of the ways for cross page communication that
do not depend on server controls, like profile, session, querystring
etc. We cannot use a cookie to carry the culture name value which comes
from the dropdown selected item value, because the culture would always
be a step behind. It would be set early on but later the dropdown
selection change it but the resources for the previous culture come up.
So normally only the page containing the dropdown would be a step
behind, but because the dropdown is in the master page it appears that
the whole site is ALWAYS ONE STEP BEHIND.&lt;br /&gt;
If, however, in the cookie, we pass the control name (which is
information that never changes, so we can never be behind), instead of
the culture name( which we can never keep up with), and then use that
key to get the form variable value, we have pieced ourselves a
workaround. &lt;br /&gt;
in the master page:&lt;br /&gt;
&amp;lt;asp&lt;img src="http://www.precharge.net/forums/images/smilies/biggrin.gif" alt="" title="Big Grin" class="inlineimg" width="16" border="0" height="16" /&gt;ropDownList
runat=&amp;quot;server&amp;quot; ID=&amp;quot;DropDownList1&amp;quot; AutoPostBack=&amp;quot;true&amp;quot;
OnSelectedIndexChanged=&amp;quot;DropDownList1_SelectedInde xChanged&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;asp:ListItem Value=&amp;quot;en&amp;quot; Text=&amp;quot;English&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;asp:ListItem Value=&amp;quot;fr&amp;quot; Text=&amp;quot;French&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;asp:ListItem Value=&amp;quot;de&amp;quot; Text=&amp;quot;German&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/asp&lt;img src="http://www.precharge.net/forums/images/smilies/biggrin.gif" alt="" title="Big Grin" class="inlineimg" width="16" border="0" height="16" /&gt;ropDownList&amp;gt; &lt;br /&gt;
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e){&lt;br /&gt;
   HttpCookie cookie = new HttpCookie(&amp;quot;DropDownName&amp;quot;);&lt;br /&gt;
   cookie.Value=DropDownList1.UniqueID;&lt;br /&gt;
   Response.SetCookie(cookie);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
in global asax&lt;br /&gt;
void Application_BeginRequest(Object sender, EventArgs e){&lt;br /&gt;
      string lang = string.Empty;//default to the invariant culture&lt;br /&gt;
      HttpCookie cookie = Request.Cookies[&amp;quot;DropDownName&amp;quot;];&lt;br /&gt;
      if (cookie != null &amp;amp;&amp;amp; cookie.Value != null)&lt;br /&gt;
         lang = Request.Form[cookie.Value];&lt;br /&gt;
      Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang);&lt;br /&gt;
      Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Notice, there is absolutely no code in any of the content pages. Thats
it ten lines of code and we are done for the whole site. This is not
complete code, just a tip and trick of using master page and the .net
event model to globalize code.&lt;br /&gt;
The new issue now is what about pages that do not have a master page?
Not all pages are strapped in a template like that. This approach can
be modified to support both. That is for next post.&lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/2677069.aspx</link><pubDate>Sat, 11 Oct 2008 17:48:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2677069</guid><dc:creator>pamelo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2677069.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=2677069</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Did anyone try Ted Pattison approach?&lt;/p&gt;&lt;p&gt;http://msdn.microsoft.com/en-us/magazine/cc163566.aspx#&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/2386288.aspx</link><pubDate>Wed, 28 May 2008 18:52:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2386288</guid><dc:creator>arxivka</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2386288.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=2386288</wfw:commentRss><description>&lt;p&gt;hello all i am creating site for english and hebrew language.&lt;/p&gt;
&lt;p&gt;a need all controls changing they place on a page then Dropdown_selectionChanged()&lt;/p&gt;
&lt;p&gt;must using session,not cookies and not application(&amp;quot;&amp;quot;)&lt;/p&gt;
&lt;p&gt;and of course dropdownlist,placed on my master page!&lt;/p&gt;
&lt;p&gt;any ideas,10q all&lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/2180057.aspx</link><pubDate>Mon, 18 Feb 2008 15:34:30 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2180057</guid><dc:creator>tkent_dna@hotmail.com</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2180057.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=2180057</wfw:commentRss><description>&lt;p&gt;The BasePage approach posted by &lt;strong&gt;EngMotagaly&lt;/strong&gt;&amp;nbsp;works like a charm.&amp;nbsp; Thanks!&lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/2139993.aspx</link><pubDate>Tue, 29 Jan 2008 16:02:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2139993</guid><dc:creator>tompy_nation</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2139993.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=2139993</wfw:commentRss><description>&lt;p&gt;I tried the method with the BasePage class, it works fine for me but in one user control my labels and textboxes arent displayed...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Anyone knows why some controls arent displayed anymore &lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/2070693.aspx</link><pubDate>Thu, 20 Dec 2007 15:46:50 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2070693</guid><dc:creator>lax4u</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2070693.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=2070693</wfw:commentRss><description>&lt;p&gt;i think i found good solution so far.&amp;nbsp; if we store CultureCode in session or cookie as suggested above then we have to repost the page. causing all the events like Init &amp;amp; page load loading twice. I think the best solution is to store Culture DropDownList&amp;#39;s UniqueID in session on masterpage&amp;#39;s init event&amp;nbsp;and then in InitializeCulture method use the following code. doing this the page will not load twice and also we dont have to use global class.&lt;/p&gt;
&lt;p&gt;&lt;span class="kwd"&gt;protected override void&lt;/span&gt; InitializeCulture()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwd"&gt;string&lt;/span&gt; selectedCulture = &lt;span class="kwd"&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwd"&gt;if&lt;/span&gt; (Session[&lt;span class="st"&gt;&amp;quot;DDLUniqueID&amp;quot;&lt;/span&gt;] != &lt;span class="kwd"&gt;null&lt;/span&gt;) // first time this will be null&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwd"&gt;string&lt;/span&gt; id = Session[&lt;span class="st"&gt;&amp;quot;DDLUniqueID&amp;quot;&lt;/span&gt;].ToString();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectedCulture = Request.Form[id]; // this will get the selected value.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwd"&gt;if&lt;/span&gt; (selectedCulture != &lt;span class="kwd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; selectedCulture != &lt;span class="kwd"&gt;string&lt;/span&gt;.Empty)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.CurrentThread.CurrentUICulture = &lt;span class="kwd"&gt;new&lt;/span&gt; CultureInfo(selectedCulture);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwd"&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.CurrentThread.CurrentUICulture = &lt;span class="kwd"&gt;new&lt;/span&gt; CultureInfo(DEFUALT_CULTURE);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwd"&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="cmt"&gt;//when request come for the first time we use browser&amp;#39;s culture.&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectedCulture = Thread.CurrentThread.CurrentUICulture.Name;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt; dc = SupportedCultures.GetSupportedCultures();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwd"&gt;if&lt;/span&gt; (!dc.ContainsValue(selectedCulture))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.CurrentThread.CurrentUICulture = &lt;span class="kwd"&gt;new&lt;/span&gt; CultureInfo(DEFUALT_CULTURE);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwd"&gt;base&lt;/span&gt;.InitializeCulture();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;p&gt;&amp;nbsp;SupportedCultures.GetSupportedCultures(); returns dictionary and&amp;nbsp;it&amp;#39;s a static method&amp;nbsp;which get all the Cultures my application supports from Cache. Use the same method to bind Culture DropDownList on masterpage. Make sure you put that dictionary in Cache so it will not hit DB each time.&lt;/p&gt;
&lt;p&gt;then on Master Page where you have dropdownlist set session. This event occurs after InitializeCulture()&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;protected void&lt;/span&gt; Page_Init(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)
{
            Session[&lt;span class="st"&gt;&amp;quot;DDLUniqueID&amp;quot;&lt;/span&gt;] = DropDownList1.&lt;font size="2"&gt;UniqueID&lt;/font&gt;;
}&lt;/pre&gt;
&lt;p&gt;then in DataBound event of DropDownList we set its selected index. make sure you use same method to bind DropDownList. In my case its SupportedCultures.GetSupportedCultures();&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;protected void&lt;/span&gt; DropDownList1_DataBound(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)
{
  &lt;span class="kwd"&gt;if&lt;/span&gt; (!IsPostBack)
  {
     &lt;span class="cmt"&gt;// we should always find the CurrentUICulture in DropDownList&lt;/span&gt;
      &lt;span class="kwd"&gt;string&lt;/span&gt; ui_culture = Thread.CurrentThread.CurrentUICulture.Name;
      ListItem item = DropDownList1.Items.FindByValue(ui_culture);
      DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(item);
   }
}&lt;/pre&gt;&lt;pre class="coloredcode"&gt;This is is working perfectly for me. Errors &amp;amp; comments will be appriciated.&lt;br /&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;here is my SupportedCulture Class&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public abstract class&lt;/span&gt; SupportedCultures
    {
        &lt;span class="kwd"&gt;private static string&lt;/span&gt; SELECT_COMMAND = &lt;span class="st"&gt;&amp;quot;select DisplayName,CultureCode from SupportedCultures&amp;quot;&lt;/span&gt;;
        &lt;span class="kwd"&gt;private static string&lt;/span&gt; CONNECTION_STRING = ConfigurationManager.ConnectionStrings[&lt;span class="st"&gt;&amp;quot;CulturesConnectionString&amp;quot;&lt;/span&gt;].ConnectionString;
        &lt;span class="kwd"&gt;private static string&lt;/span&gt; CACHE_KEY = &lt;span class="st"&gt;&amp;quot;CULTURES&amp;quot;&lt;/span&gt;;

        &lt;span class="kwd"&gt;public static&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt; GetSupportedCultures()
        {
            SqlDataReader reader = &lt;span class="kwd"&gt;null&lt;/span&gt;;
            SqlConnection con = &lt;span class="kwd"&gt;null&lt;/span&gt;;
            Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt; supportedCultures = &lt;span class="kwd"&gt;null&lt;/span&gt;;
            &lt;span class="kwd"&gt;try&lt;/span&gt;
            {
                &lt;span class="kwd"&gt;if&lt;/span&gt; (System.Web.HttpContext.Current.Cache[CACHE_KEY] != &lt;span class="kwd"&gt;null&lt;/span&gt;)
                    supportedCultures = (Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt;)System.Web.HttpContext.Current.Cache[CACHE_KEY];
                &lt;span class="kwd"&gt;else&lt;/span&gt;
                {
                    con = &lt;span class="kwd"&gt;new&lt;/span&gt; SqlConnection(CONNECTION_STRING);
                    SqlCommand selectCommand = &lt;span class="kwd"&gt;new&lt;/span&gt; SqlCommand(SELECT_COMMAND, con);
                    con.Open();
                    reader = selectCommand.ExecuteReader();
                    &lt;span class="kwd"&gt;if&lt;/span&gt; (reader != &lt;span class="kwd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; reader.HasRows)
                    {
                        supportedCultures = &lt;span class="kwd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt;();
                        &lt;span class="kwd"&gt;while&lt;/span&gt; (reader.Read())
                        {
                            &lt;span class="kwd"&gt;string&lt;/span&gt; k = reader.GetString(reader.GetOrdinal(&lt;span class="st"&gt;&amp;quot;DisplayName&amp;quot;&lt;/span&gt;));
                            &lt;span class="kwd"&gt;string&lt;/span&gt; v = reader.GetString(reader.GetOrdinal(&lt;span class="st"&gt;&amp;quot;CultureCode&amp;quot;&lt;/span&gt;));
                            supportedCultures.Add(k, v);
                        }
                    }

                    System.Web.HttpContext.Current.Cache[CACHE_KEY] = supportedCultures;
                }
            }
            &lt;span class="kwd"&gt;finally&lt;/span&gt;
            {
                &lt;span class="kwd"&gt;if&lt;/span&gt; (con != &lt;span class="kwd"&gt;null&lt;/span&gt;)
                    con.Close();
                &lt;span class="kwd"&gt;if&lt;/span&gt; (reader != &lt;span class="kwd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !reader.IsClosed)
                    reader.Close();
            }
            &lt;span class="kwd"&gt;return&lt;/span&gt; supportedCultures;
        }      
    }&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/2070476.aspx</link><pubDate>Thu, 20 Dec 2007 14:13:07 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2070476</guid><dc:creator>Thelma</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2070476.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=2070476</wfw:commentRss><description>&lt;p&gt;Thanks so much for this thread, it really helped me so much. Also thanks to you Dan Ludwig as your hint to use the application_preRequestHandler was what I was looking for.&lt;/p&gt;
&lt;p&gt;I wanted to change the language depending on a users role. I work with other developers on the same project so I did not want to have to change every page to inherit from a basepage class. &lt;/p&gt;
&lt;p&gt;So the Application_PreRequestHandlerExecute(&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;font size="2"&gt; sender, &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;EventArgs&lt;/font&gt;&lt;font size="2"&gt; e) function on the global.asax page really helped..&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Incase anyone is interested, the following is the code that worked for me in the end:&lt;/font&gt;&lt;/p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (HttpContext.Current.User != null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!HttpContext.Current.User.IsInRole(&amp;quot;French&amp;quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(&amp;quot;en-GB&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&amp;quot;en-GB&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;The above code uses the default culture if the user is in role &amp;#39;French&amp;#39; otherwise it sets the culture to &amp;#39;en-GB&amp;#39;.&lt;/p&gt;
&lt;p&gt;Thel&lt;br /&gt;&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/2058533.aspx</link><pubDate>Thu, 13 Dec 2007 19:20:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2058533</guid><dc:creator>lax4u</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2058533.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=2058533</wfw:commentRss><description>&lt;p&gt;problem with &lt;a href="http://forums.asp.net/members/EngMotagaly.aspx"&gt;&lt;font color="#034efa"&gt;EngMotagaly&lt;/font&gt;&lt;/a&gt; code is that, the basepage &amp;amp; master page both loads twice, when user change culture in dropp down list.&lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/1982794.aspx</link><pubDate>Wed, 31 Oct 2007 10:38:34 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1982794</guid><dc:creator>raybiez</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1982794.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=1982794</wfw:commentRss><description>&lt;p&gt;Here is how you should apply it. Suppose you have placed the above mentioned class source in a file called BasePage.cs and placed it in the App_Code directory.&lt;/p&gt;&lt;p&gt;Should you create a new aspx page named MyPage under a directory MyDir, the code behind will look like so:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Data;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Configuration;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Collections;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.Security;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.UI;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwd"&gt;public&lt;/span&gt; partial &lt;span class="kwd"&gt;class&lt;/span&gt; MyDir_MyPage : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwd"&gt;protected void&lt;/span&gt; Page_Load(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;br /&gt;You should change it so it looks like so:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Data;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Configuration;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Collections;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.Security;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.UI;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;&lt;br /&gt;&lt;span class="kwd"&gt;using&lt;/span&gt; System.Web.UI.HtmlControls;&lt;br /&gt;&lt;span class="kwd"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwd"&gt;public&lt;/span&gt; partial &lt;span class="kwd"&gt;class&lt;/span&gt; MyDir_MyPage : BasePage&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwd"&gt;protected void&lt;/span&gt; Page_Load(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&amp;nbsp;&lt;br /&gt;What you have done is to declare that your page is a derivative of the BasePage class, which in turn is of System.Web.UI.Page class. So all methods &amp;amp; properties would have been inherited.&lt;br /&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/1908296.aspx</link><pubDate>Fri, 14 Sep 2007 01:04:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1908296</guid><dc:creator>anilraja</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1908296.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=1908296</wfw:commentRss><description>&lt;p&gt;After creating this class, I have put this class in App_Code folder. Please tell me how to call this class. Shall I call from master page or Default.aspx page or from Global.aspx class from Application_start method? Shall I have to do &lt;/p&gt;
&lt;p&gt;Base bs = new Base();&lt;/p&gt;
&lt;p&gt;?&lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/1887632.aspx</link><pubDate>Fri, 31 Aug 2007 19:48:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1887632</guid><dc:creator>shawnregan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1887632.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=1887632</wfw:commentRss><description>&lt;p&gt;By using the code that was givin in this thread the transalation will not happen auto for you. Any static text that you may have on the page needs to be placed in a localize control and the page needs to have an .resx for each language you want to support. The .resx files hold static text to be placed on the .aspx at runtime.&lt;/p&gt;
&lt;p&gt;Example: You have a home page called &lt;strong&gt;home.aspx&lt;/strong&gt; and in &lt;em&gt;&lt;strong&gt;App_LocalResources&lt;/strong&gt;&lt;/em&gt; you have &lt;strong&gt;home.ascx.resx &lt;/strong&gt;which would be your&amp;nbsp;default supported langauge.&lt;strong&gt;&amp;nbsp;Y&lt;/strong&gt;ou&amp;nbsp;will also need to have one for each language. &lt;/p&gt;
&lt;p&gt;French: home.ascx.fr.resx&lt;br /&gt;Spanish: home.ascx.es.resx&lt;/p&gt;
&lt;p&gt;etc...&lt;/p&gt;
&lt;p&gt;No, way to do any auto translation of everything for a site. You still need to translate your pages and data. :)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Check this video out for just this topic on localization: &lt;a href="http://www.asp.net/learn/ajax-videos/video-179.aspx"&gt;http://www.asp.net/learn/ajax-videos/video-179.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It does some with ajax, but it also shows the basics for localization.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/1815047.aspx</link><pubDate>Fri, 20 Jul 2007 16:54:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1815047</guid><dc:creator>vb89</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1815047.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=1815047</wfw:commentRss><description>Hey &lt;strong&gt;danludwig&amp;nbsp;&lt;/strong&gt;I tried using your code for my page, and instead of spanish i changed it to German(the language im trying to translate the page to) but the problem is that nothing happens when I select german on the drop down...any ideas?</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/1642396.aspx</link><pubDate>Thu, 29 Mar 2007 07:53:32 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1642396</guid><dc:creator>sinner850408</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1642396.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=1642396</wfw:commentRss><description>Creating a Base class inheriting from Page is the best way.</description></item><item><title>Re: How to do a language switch in a master page.</title><link>http://forums.asp.net/thread/1639014.aspx</link><pubDate>Tue, 27 Mar 2007 13:17:30 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1639014</guid><dc:creator>alug</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1639014.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=13&amp;PostID=1639014</wfw:commentRss><description>&lt;p&gt;Hi:&lt;/p&gt;
&lt;p&gt;You can find help in this context from the following URL.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.codeproject.com/useritems/localization.asp"&gt;http://www.codeproject.com/useritems/localization.asp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind Regards&lt;/p&gt;</description></item></channel></rss>