Here is the solution to How to dynamically load images within a custom control with images embedded with it! Context: You have a project of type "Class Library" where you create your custom control MyCC. 1/ Add a new item: Resources File: Resources.resx 2/ Drag your images onto this resource file you had open. This will generate a sub folder named Resources containing all images dragged. 3/ Under "Solution Explorer", select each image file to change their "Build Action" property to "Embedded Resource". 4/ Set the image url property as follow in the overrided Render() or RenderControl() method depending which one you are using to generate the HTML of your custom control:
this._myImage.ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyNameSpace.Resources.MyImage.gif");
The second param is of structure: [Namespace].[Resources Folder].[Resource File Name] 5/!!!! Carefull, the Namespace above and below has to match the default one defined in the project properties (Tab "Application"). 6/ Last, either in your custom control .cs file or in your AssemblyInfo.cs, add this line for each image: [assembly: System.Web.UI.WebResource("MyNameSpace.Resources.MyImage.gif", "image/gif")] Conclusion: Like this any page using your custom control will be able to display any image declared in your custom control. Note: If you look at your page source when you run it, the src attribute of your image uses a WebResource.axd. Enjoy. If I have missed anything, I apologize.
"Nothing is lost, Nothing is created, Everything is transformed" Lavoisier