Julian Jelfs’ Blog

ClientScriptManager.GetWebResourceUrl type parameter

Posted in Uncategorized by julianjelfs on November 22, 2009

So this method returns a URL reference to a resource embedded in an assembly. No problem with that – useful. The thing that annoys me about this is the first parameter. It is a parameter of type “Type” and according to the documentation describes the type of the resource. This is obviously nonsense. If I am embedding a javascript file in an assembly what type is that? typeof(javascript file) ? In the remarks section on the documentation we get a bit more information:

“You specify the type based on the object that will be accessing the resource”

Which seems again to be meaningless. What does this mean for a script file? It turns out that the only thing you have to make sure of really is that the type you specify belongs to the same assembly that the resource is embedded in otherwise it will not work. This is the one important point that the documentation does not clearly tell you.

Advertisements