2013-01-17 38 views
0

我正在使用WIndows 8Visual Studio 2012 Metro。我需要添加一個DropDownList並讓用戶選擇語言。當用戶選擇一種特定的語言時,我需要標籤中的所有文本值來更改爲特定的語言。MultiLanguage - 邏輯錯誤初學者

I followed this tutorial

I R-CLick project added `APPGlobal_Resource` folder 
I R-Clicked and added `APPGlobal_Resource` and created a Resource file called rss.resx 
Then i duplicated this file and named it rss.fr.resx 
I gave 2 values `String1` and `Hello` and `Bonjour` as values (in both files) 
R-Click `dropdownlist` and `edit item`, and `ADD` and then gave `en-US` as `Name` and `value`as `en-US` (same way i gave `en-fr`) 
Then i set the Label property, `Data (Expression)` `Bindable property` to `Text` and `Expression Type` to `Resources`. 

I gave the `Class Key` to `Res` and `Resource Key` to `String1`. 

和我寫了下面的代碼Default.aspx.cs

protected override void InitializeCulture() 
     { 
      base.InitializeCulture(); 
      String cult = Request["DropDownList1"]; 

      if (cult != null) 
      { 
       Culture = cult; 
       UICulture = cult; 
      } 
     } 

下視顯示器的下降與en-US and en-fr但是當我選擇它沒有什麼變化。我該如何解決這個問題?

+0

我編輯了自己的冠軍。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –

回答

1

不知道,但它可以幫助:

System.Threading.Thread.CurrentThread.CurrentCulture = 
    new System.Globalization.CultureInfo(cult); 
+0

我應該在哪裏添加? –

+0

在'if(cult!= null)'子句 –

+1

但我仍然認爲文化'en-fr'根本就不存在 –