2013-03-06 73 views
0

的Web.config變化曲線語言

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

Default.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:

  • 爲Default.aspx.resx
  • Default.aspx.fr。 resx

這是我的錯誤:

Object reference not set to an instance of an object. 

什麼我錯了,我想我的法語文本?

+0

有一個對象 「空」 不在你的代碼中初始化?如果是,是否可以指定哪個對象== null?使用System.Globalization的 – 2013-03-06 16:52:46

回答

1

你可以試試嗎?

或看起來更這裏

贏形式C# - >Change language of WinForm with resource

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(); 
    } 
+0

;使用System.Threading的 ; – 2013-03-06 17:20:32