less than 1 minute read

Scott Guthrie writes:

…if you have images only used by that user control, you can create a “images” directory that lives in the same directory as your usercontrol – and then use relative paths to the images using asp.net server controls. For example:

<img src="image/foo.jpg" runat="server"/>

Or

<asp:image imageurl="image/foo.jpg" runat="server"/>

ASP.NET will then automatically fixup the path to the image to be based on the physical path of the user control. That way, regardless of what page the user control is used on (even if a different subhierarchy), you’ll get the right path to the image. Internally we use the Page.ResolveUrl(path) method…

Updated: