Playing with Images in ASP.NET 3.5 AJAX Applications - Hacking the HTML
(Page 2 of 5 )
On the whole, there is merely one way to refer to an image in an HTML page-using the HTML <img> element. The following lists the simple and typical form of usage for the <img> mark:
<img id="ImgID"
alt="alternate text for the image"
align="top|middle|bottom|left|right"
border="border width"
height="image height"
src="the url to the special image file"
width="image width" />
Author's Note: in the case of Microsoft Internet Explorer, the <img> mark is designed to embed both an image and a video clip in a web page. When using the img element to display a static image, specify the URL of the image file with the src attribute. When using the img element to display a video clip or virtual reality modeling language (VRML) world, specify the URL with the dynsrc attribute. Regrettably, due to the well-known incompatibility between browsers, Mozilla Firefox does not support the video clip functionality.
To show an image at the web page you have to provide the corresponding URL that identifies an image. In many cases, the URL points to a static image resource, such as an .gif, .png or .jpeg file. The following concludes the entire image and video file formats supported by IE:
.avi-Audio-Visual Interleaved (AVI)
.bmp-Windows Bitmap (BMP)
.emf-Windows Enhanced Metafile (EMF)
.gif-Graphics Interchange Format (GIF)
.jpg, .jpeg-Joint Photographic Experts Group (JPEG)
.mov-Apple QuickTime Movie (MOV)
.mpg, .mpeg-Motion Picture Experts Group (MPEG)
.png-Portable Network Graphics (PNG)
.wmf-Windows Metafile (WMF)
Note in the "static" resource scenarios, the web server can serve incoming requests of this kind internally, independent of the out-most components. However, this is only one of the cases; the image data in practical situations for the <img> element may reside in other kinds of storage media, such as databases, .NET assemblies, or even the memory of the web servers.
In ASP.NET, the HtmlImage class is utilized to describe and render the <img> mark; however, besides providing more flexible control over the images, this merely means one of many possible ways to create the <img> mark. Another apparent alternate method to rendering an image on a web page is to leverage the original html <img> element.
Digging more into the inner workings behind the exterior <img> mark, we should notice that the URL of an <img> mark can point to more than an static and direct path of an image in order to render an image on the web page. Suppose the URL points to an .aspx page. The web server will run the specified page and dispatch the final result to this attribute. Experiments show that as long as this result is pointing to some valid image format, it can be rendered onto the screen.
Next: A Few words about the HTTP Handler >>
More ASP.NET Articles
More By Xianzhong Zhu