Welcome to the Dot Net Tech Community

Experience The Freedom To Share...

Monday, June 21, 2010

Embeding Images in Custom Control

Steps to embed images in a custom control (.dll)
1. Adding Images to the solution.
Add images to the soution.
Right click the image and set the Build action to "Embeded Resource".
2. Declaring the image to be a web resource
Add the following line to the assemblyinfo.cs
[assembly: WebResource(".[folder].", "image/gif")]
3. Access the file in the code
Page.ClientScript.GetWebResourceUrl(this.GetType(), ".[folder].");
Done... you can now embed the images, .js files or .css files to the dlls.
This article also appears on Experts Exchange Embeded Resources in dlls

No comments:

Post a Comment