Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access GetGlobalResourceObject()

Tags:

namespaces

c#

I'm new to c#. I have this class...

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public class clsErrorMessages
{
    string _sErrors;
    public clsErrorMessages(string sErrorTextFileName)
    {
        _sErrors = (String)GetGlobalResourceObject("resource","FriendlyErrors.txt");

    }
}

The compiler says the name 'GetGlobalResourceObject' does not exist in the current context

Do I need to include another using?

like image 685
El Ronnoco Avatar asked Nov 11 '10 11:11

El Ronnoco


1 Answers

The GetGlobalResourceObject() method is a static member of the HttpContext class. You need to qualify it as such:

_sErrors = (string) HttpContext.GetGlobalResourceObject("resource",
    "FriendlyErrors.txt");
like image 86
Frédéric Hamidi Avatar answered Nov 10 '22 00:11

Frédéric Hamidi