Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a resorce file as res.en-US.resx and res.hi-IN.resx with key-value as
SQL
key       value 

btnidNew  New
btn_Refresh Refresh


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");


C#
public static string GetLocalValue(string Key)
   {
       return ResProvider.GetLocalValue(Key, Culture);
   }


C#
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
Posted

1 solution

Hi,

in aspx page, you can get resource name as follow:


<asp:Label ID="Label1" runat="server" Text="<%$Resources:fileName, btnidNew %>"></asp:Label>

in code behind use follow

Resources.fileName.btnidNew.ToString()


Hope this will help you.
 
Share this answer
 
Comments
aassaahh 19-Aug-14 0:45am    
when i tried this code "Resources.fileName.btnidNew.ToString()" it showing Resources was not found in the current context
aassaahh 19-Aug-14 0:50am    
i am able to use ResourceManager class

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900