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.

function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } function AcceptCookies() { createCookie("cookie-site","true",120); createCookie("cookie-tracking","true",120); createCookie("cookie-remarketing","true",120); document.getElementById("overlay").style.display = "none"; } ]]>

Cookies

This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.