In our .aspx pages, we've got lots of this code:
<%= CType(GetLocalResourceObject("key"), String)) %>
I'd like to add an extension method that I can use in our .aspx views that allows me to do this:
<%= GetLocalResourceString("key") %>
The code isn't working, though:
Imports System.Runtime.CompilerServices
Imports System.Web.UI
Module Extensions
<Extension()>
Public Function GetLocalResourceString(ByVal control as TemplateControl,
ByVal resourceKey as String) as String
Return CType(control.GetLocalResourceObject(resourceKey)), String)
End Sub
End Module
According to Intellisense, the problem is that GetLocalResourceObject doesn't exist as a method of System.Web.UI.TemplateControl objects.
However, when I look at this page on MSDN, it's there.
What am I doing wrong? Should the extension method be on a different object? I've tried others and have the same Intellisense/build error.