The best way to illustrate what I'm trying to achieve is with code:

namespace MyWebApp
{
    public static class Funcs
    {
        public static string readResxParamForPage(System.Web.UI.TemplateControl pageTmpl, string strParamID)
        {
            string strRes = "";

            object obj = pageTmpl.GetLocalResourceObject(strParamID + ".Text");   //ERROR CS0122 here
            if (obj != null)
            {
                //Got it
                strRes = obj.ToString();
            }

            return strRes;
        }
    }
}


namespace MyWebApp
{
    public partial class MyPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string strThisPageIs = Funcs.readResxParamForPage(this, "PageName");
        }

    }
}

My goal is to access resource local for a page from a static method via a pointer to that page.

But the code snippet above produces the following error:

error CS0122: 'System.Web.UI.TemplateControl.GetLocalResourceObject(string)' is inaccessible due to its protection level

Any idea how to fix it?

Related posts

Recent Viewed