Saturday, May 28, 2011

Asp.net: Fetch Images in Resx(Resource) file

Hi,

What ever need or scenario, here i am explaining, how to access image-files
stored in Resource file (Resx) from Asp.net page.

i used Asp.Net 3.5
since Html-Image elements can't be assigned with (image in Resx) streams directly, i use Handler file (ashx), which handles the image serving to Html-Image controls.

The Resource file has (embedded) 3 images, the 3 Html-Image elements in webpage access these 3 images via Handler.

Below is the image showing request-reply process.



Below is the image showing output of the webpage.



The Handler file is UI-less, which is useful for serving the serverside resources.
Instead of directly flushing the image stream to browser, (in which case, only image will be displayed without content) i used Html-image controls to point to the handler file, because, we don't want just only the flushed image get displayed.

Download the files and check the code. From Here!

No comments:

Post a Comment