Reputation: 139
How can I use an image or icon resource from global resource file in an asp:Image control to set the ImageUrl attribute?
Upvotes: 4
Views: 1409
Reputation: 116987
In code:
ClientScriptManager cs = Page.ClientScript;
myImage.ImageUrl= cs.GetWebResourceUrl(type, "resource name");
In the markup:
<asp:Image
ImageUrl="<%= Page.ClientScript.GetWebResourceUrl(typeof(MyClass),
"resource name") %>"
/>
See the documentation for ClientScriptManager.GetWebResourceUrl for more info.
Upvotes: 1