ASP code to pass parameters in the URL for an image component

When an image is streamed from a script the script must be embedded inside an <img> tag and this causes problems when trying to pass variables through the application. A useful method is to use the URL to the embedded script to pass query string parameters.

The example on the previous page shows a script that draws a red square. With some modifications this colour could could be passed in the URL. Here is the new <img> tag:

<img src="image.asp?Colour=FF0000">

The script generating the image would use the parameter as follows:

Set Image = Server.CreateObject("csImageFile.Manage")
Image.NewImage 200, 200, Request.Querystring("Colour")

Remember to use Server.URLEncode if the parameters could contain characters that need encoding.