How can I use an image or icon resource from global resource file in an asp:Image control to set the ImageUrl attribute?
views:
84answers:
1
+1
A:
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.
womp
2010-01-12 17:22:37
I used the code in the markup and I got this error Server tags cannot contain <% ... %> constructs.
2010-01-13 09:06:00
Use the "In code" example instead. Put it in the Page_Load event.
awe
2010-02-12 14:53:01