-1

I'm trying to access my global.resx file from a static method... this is what i have

public static string GetElementTextLabel(string attributeName)
{
        string retValue = string.Empty;
        try
        {
            retValue = (string) HttpContext.GetGlobalResourceObject("Global", attributeName) ?? "(value needed)";  

        }
        catch (NotImplementedException ex)
        {
            throw;
        }

        return retValue;
}

I get the following error: it's giving an error, saying "An object reference is required for the non-static field, method, or property 'System.Web.Mvc.Controller.HttpContext.get'

how can i use the parameter in my search for the resource value... if i remove the static then it works fine but now i need this method static

fifamaniac04
  • 2,063
  • 10
  • 45
  • 67
  • 2
    the error is telling you what the problem is.. are you familiar with the difference between Instance and static..? – MethodMan Apr 21 '15 at 18:06

1 Answers1

0

You could write it as an extension method:

public string GetElementTextLabel(this ExtObject obj, string attributeName)

Where obj is whatever instance of an object you find suitable.

beautifulcoder
  • 9,006
  • 3
  • 16
  • 26