0

网页配置

<profile>
      <properties>
      <add name="Language"  />
      </properties>
</profile>

默认.aspx.cs

protected void Page_Load(object sender, EventArgs e)
    {
        Profile.Language = "fr";
        string strCultur = Profile.Language;
        Page.Culture = strCultur;
        Page.UICulture = strCultur;
        lblLabel.Text = GetLocalResourceObject("lblLabelResource1").ToString();
    }

App_LocaleResource:

  • 默认.aspx.resx
  • Default.aspx.fr.resx

这是我的错误:

Object reference not set to an instance of an object.

我有什么错我想要我的法语文本?

4

1 回答 1

1

你可以试试这个吗?

或在这里查看更多

win form c# -> 使用资源更改 WinForm 的语言

using System.Globalization; 
using System.Threading;


//LanguageString sample
String languageString = "fr-FR";
//Apply new language
Thread.CurrentThread.CurrentUICulture = new CultureInfo(languageString);
Application.Run(new Form());

asp.net c# -> http://forums.asp.net/t/1244851.aspx/1

protected override void InitializeCulture()
    {
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

        base.InitializeCulture();
    }
于 2013-03-06T16:56:54.017 回答