Last post Apr 13, 2009 04:27 AM by galankar.tushar
Apr 07, 2009 09:38 AM|aaishinsky|LINK
Hello, I'm trying to create Web Custom Control. The purpose of this control is to display company banner on the top of the page. The banner it self is Image file( it could be Bitmap, Jpeg or other format). I'm trying to store this Image in Resource file
and when I build "Child Controls" on this Web Custom Control, I want to set HtmlImage to display stored image from Resource file. Right now, I'm having problem to do so. If you have any suggestions, please let me know. Thanks in advance!
Apr 07, 2009 02:33 PM|WebPrgmer|LINK
You mean your Image is an Embedded Resource?
If your Custom Control has only 1 Image and you are deriving from Image then not sure why you are trying to overwrite CreateChildControls.
Instead in Render try: base.ImageUrl = Page.ClientScript.GetWebResourceUrl(typeof(what_ever), "<location of your embedded image>");
Apr 13, 2009 04:27 AM|galankar.tushar|LINK
I will reccomend you that..if you are developing a custom control, then you should use embedded resouce for your custom control. This will reduce your deployment dependancy ( deploying default image. which is not a good practise)
You have to add this default image in the class library as a embedded resource.
Please Read about embadded resource.
Here is the code for this.
[assembly: WebResource("MyPortal.Images.Default_image.gif", "image/gif")]
public class MyControl1: WebControl
/// URL of the image to be shown when the Asynchronous process is initiated.
[Description("URL of the image to be shown when the Asynchronous process is initiated.")]
//This attribute is edded to display the UrlEditor to user, which is used to select the proper image file.
public string ImageUrl
string s = (string)ViewState["ImageUrl"];
s = Page.ClientScript.GetWebResourceUrl(GetType(), "MyPortal.Images.Default_image.gif");
ViewState["ImageUrl"] = s;
ViewState["ImageUrl"] = value;
This will definitly solve your problem
Please mark as answer, if this post works