1. You have a solution with a web project and a separate class project
2. In Visual Studio, drag the image you want to embed into your class project
3. In the Properties window of the Image, select Build Action: Embedded Resource
4. Add a new class to the project, call it EmbeddedResources.cs for the sake of argument. Put the following code in it:
[assembly: WebResource("YourProjectAssemblyNamespace.YourPic.jpg", "image/jpeg")]
namespace YourProjectAssemblyNamespace
{
public class EmbeddedResources
{
}
}
5. Reference the image from your web project like so:
<img src="<%= Page.ClientScript.GetWebResourceUrl(typeof(YourProjectAssemblyNamespace.EmbeddedResources), "YourProjectAssemblyNamespace.YourPic.jpg") %>" />
Woop!
No comments:
Post a Comment
Comments are very welcome but are moderated to prevent spam.