MultiLanguage - 逻辑错误初学者

时间:2013-01-17 19:40:35

标签: c# asp.net visual-studio-2012

我正在使用WIndows 8Visual Studio 2012 Metro。我需要添加DropDownList并让用户选择语言。当用户选择特定语言时,我需要标签中的所有文本值更改为该特定语言。

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但是当我选择它时没有任何变化。我怎么解决这个问题?

1 个答案:

答案 0 :(得分:1)

不确定,但它可以提供帮助:

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