无法使用HttpContext.GetGlobalResourceObject从全局resorce文件中读取值 [英] unable to read values from global resorce file using HttpContext.GetGlobalResourceObject
本文介绍了无法使用HttpContext.GetGlobalResourceObject从全局resorce文件中读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有res.en-US.resx和res.hi-IN.resx的resorce文件,键值为
Hi,
I have a resorce file as res.en-US.resx and res.hi-IN.resx with key-value as
key value
btnidNew New
btn_Refresh Refresh
我想从资源文件中读取值,并在标签或div中将其dsislay用于本地化
因为我有wriiten代码为
I want to read value from the resource file and dsislay it in label or div for localisation
for that i have wriiten code as
btn_Refresh.Value = ResourceProvider.GetLocalValue("btn_Refresh");
public static string GetLocalValue(string Key)
{
return ResProvider.GetLocalValue(Key, Culture);
}
public string GetLocalValue(string Key, CultureInfo Culture)
{
string retVal = string.Empty;
try
{
retVal = HttpContext.GetGlobalResourceObject("res", Key, Culture).ToString();
//retVal = HttpContext.GetLocalResourceObject("loc", Key, Culture).ToString();
}
catch (Exception ex)
{
//do any loging
string jjj = "";
jjj = "ffffff";
// NullReferenceException es;
}
return retVal;
}
但它返回空字符串。请帮助或提供一些替代解决方案
but it is returning empty string .Please help or provide me some alternative solution
推荐答案
在aspx页面中,您可以获得如下资源名称:
< asp:Label ID =Label1runat =serverText =<%
Hi,
in aspx page, you can get resource name as follow:
<asp:Label ID="Label1" runat="server" Text="<%
资源:fileName,btnidNew%>>< / asp:标签>
使用后面的代码 < br $>
Resources.fileName.btnidNew.ToString()
希望这个会帮助你。
Resources:fileName, btnidNew %>"></asp:Label>
in code behind use follow
Resources.fileName.btnidNew.ToString()
Hope this will help you.
这篇关于无法使用HttpContext.GetGlobalResourceObject从全局resorce文件中读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文