1

I am working on a Custom Composite ASP.net Server Control.

It requires to call up images, and I´ve added said images as an embedded resource. However, doing so I can only get the image as a bitmap file, and i need to pass the file to an Image Control, which only takes ImageURL, or string path. How can I reference the file sin my resources? Supossing i have images called "image1.gif" in my resources if i code:

Resources.image1

I get the object as an image, but i don't know how to get a path, so that i can give it directly to my Image component.

Thanks in advance!

EDIt:

string[] alarmArrayString = new string[5]; Through a for loop I am assigning the appropriate values. I checked it during debugging and all 5 placeholders had an appropriate value.

These are being populated correctly, it seems the problem is with the Page.ClientScript, or the getting Type.

For example:

orangeAlarm = new Image();
            orangeAlarm.ID = "orangeAlarmObject";
            orangeAlarm.ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), alarmArrayString[1]);

I separated the Page.ClientScript and this.GetType as:

ClientScriptManager cs = Page.ClientScript; Type rsType = this.GetType();

And I get the exception error on both of those...

Extra:

AssemblyInfo.cs sample: [assembly: System.Web.UI.WebResource("RDCButtonTest.Resources.401.gif","image/gif")] [assembly: System.Web.UI.WebResource("RDCButtonTest.Resources.410.gif","image/gif")] [assembly: System.Web.UI.WebResource("RDCButtonTest.Resources.411.gif","image/gif")]

SlickD
  • 45
  • 1
  • 11
  • possible duplicate of [How to use image resource in asp.net website?](http://stackoverflow.com/questions/244807/how-to-use-image-resource-in-asp-net-website) – Shadow The GPT Wizard Jan 24 '12 at 13:23
  • [This](http://geekswithblogs.net/shahed/archive/2008/04/12/121211.aspx) might also help. – Shadow The GPT Wizard Jan 24 '12 at 13:24
  • Thanks for replying It is similar but not quite. I am trying to do all this on the server side, meaning onlyin C#! – SlickD Jan 24 '12 at 14:01
  • Not getting what you mean. Both linked posts use server side code, VB.NET can be easily converted to C# if that's what you need. – Shadow The GPT Wizard Jan 24 '12 at 14:08
  • Oh got it, ok I see what they are doing, and Ive been able to link to my resource, but the code provided, and ive now seen it elsewhere is the following: Page.ClientScript.GetWebResourceUrl(typeof(RDCButtonTest.RDCButton), alarmArrayString[1]); and it gives me an error, saying the object is not set to an instanceof the object? – SlickD Jan 24 '12 at 14:21
  • What is `alarmArrayString`? Where is it defined? Please edit your question with the relevant code and details. – Shadow The GPT Wizard Jan 24 '12 at 14:44

0 Answers0