根据两种文化,我需要以我的形式更改控件的属性
其中指定了.resx文件
resorces1.aspx.resx // default resorces1.aspx.he-IL.resx // hebrew culture
我可以使用回退资源加载页面,或者通过pageload给出UICulture =“he-IL”值,并且可以使用所需的资源加载页面.
问题是我需要在运行时进行这些更改.
1 ..在我更改一个按钮点击事件的值后
btn_change_Click(....) { UICulture = "he-IL" ; }
它仍然返回到初始化值“en-US”
在运行时如何对UICulture进行更改?
2 ..如果我不知道它是“en-US”,怎么能引用后备资源文件?
解决方法
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("he-IL");
或者更好的是,检索他的IL-IL文化的缓存的只读实例:
System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("he-IL");
At run time,ASP.NET uses the resource file that is the best match for the setting of the CurrentUICulture property. The UI culture for the thread is set according to the UI culture of the page. For example,if the current UI culture is Spanish,ASP.NET uses the compiled version of the WebResources.es.resx file. If there is no match for the current UI culture,ASP.NET uses resource fallback. It starts by searching for resources for a specific culture. If those are not available,it searches for the resources for a neutral culture. If these are not found,ASP.NET loads the default resource file. In this example,the default resource file is WebResource.resx.
原文地址:https://www.jb51.cc/csharp/96584.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。