Is there a way to move a call to ASP GetLocalResou

2019-08-31 01:39发布

I am using local resource strings in ASP. My strings are something like "This is a {0}" I am using String.Format to replace the {0} value.

In anycase, rather the put this code in every page, I wanted to create a Static/Shared method that any page could call. I had thought that I could pass the page in and call the GetLocalResourceObject() method. GetLocalResourceObject() is protected so its not valid.

Is there a way to call this external to the code-behind?

Shared Function GetPatternedResourceString(Byval P as Page, ByVal key As String, ByVal replacement As String) As String

        Return String.Format(p.GetLocalResourceObject(key), replacement)

    End Function

I realize there are some other ways to get a local resource, I think there is one on HttpContext but you need to do some extra work and pass in url paths, etc.

This is actually the same problem listed here VB.NET: Extension method for pages that uses GetLocalResourceObject

1条回答
你好瞎i
2楼-- · 2019-08-31 02:06

GetLocalResourceObject() - Gets a page-level resource object based on the specified VirtualPath and ResourceKey properties. For more clarification you should read this

查看更多
登录 后发表回答