Asp.net 下拉控件中的元属性?

Asp.net 下拉控件中的元属性?,asp.net,Asp.net,可能重复: 在asp.net中。在dropdownlist控件中使用“meta:resourceKey”有什么用 <asp:ComboBox ID="ddlAccounts" runat="server" Width="130px" MaxLength="0" meta:resourcekey="ddlAccountsResource1" style="display: inline;" AutoCompleteMode="SuggestAppen

可能重复:

在asp.net中。在dropdownlist控件中使用“meta:resourceKey”有什么用

  <asp:ComboBox ID="ddlAccounts" runat="server" Width="130px" MaxLength="0" 
        meta:resourcekey="ddlAccountsResource1" style="display: inline;" 
        AutoCompleteMode="SuggestAppend" ItemInsertLocation="OrdinalText">
    </asp:ComboBox>

谁能给我解释一下吗

我使用meta:resourcekey=“myString”和资源(xml)文件来支持多语言。您可以有许多资源文件(每种语言一个),每个文件都有相同的密钥。键值因语言而异。您的aspx文件将根据页面区域设置从相关资源文件中读取

例如,我对英语资源(字符串)使用资源文件Default.aspx.resx,对法语资源使用Default.aspx.fr-fr.resx

然后,我将以下代码添加到每个.aspx页面。也许有一个更整洁的方法,但这对我来说很有效

protected override void InitializeCulture()
{
    if (Request.QueryString["lang"] == "fr")
    {
        base.InitializeCulture();
        System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
        System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
    }
    else
    {
        base.InitializeCulture();
        System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
        System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
    }
}

检查这个答案,了解一些细节:哎呀,刚刚意识到你的问题是关于下拉列表的,不过上面的答案可能对其他人有帮助,所以我会保留它。