Printed numbers on custom pushpin

This Page is locked
Modified: 2007/05/16 15:51 by ViaVE Visitor
Version 5 supports custom html allowing this to be on the client see: KeithK's blog article

well, printing numbers on the pushpin for example can be done if you create an .aspx page that doesnt deliver html content, but the pushpin image with a number on it.

Example:

we name our page Pushpin.aspx

we call it via pushpin.aspx?Number=<your number goes here>

in the page code, you do following:


FileStream stream = new FileStream("pushpin.gif");

Image img = Image.FromStream(stream);

stream.Close();

Graphics g = Graphics.FromImage(img);

g.DrawString(Request.QueryString["Number"],new Font("Arial",10), Brushes.Black, new PointF(0,0));

g.Dispose();

Response.ContentType = "image/gif";

img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
thats it, now your pushpin.aspx doesnt spit out html content but your custom pushpin image.

••• Using a custom IHttpHandler .ashx is more efficient than using an aspx since the Page Handler has a lot of infrastructure and code that is totally unused in this case. You can pretty much take the code above and put it in ProcessRequest method of an IHttpHandler class.