开发者

Is there a way to move a call to ASP GetLocalResourceObject to a external static/shared method?

开发者 https://www.devze.com 2023-03-07 07:08 出处:网络
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.

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 thi开发者_Python百科s 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消