Create a generic handler that streams back an image. Pass it an identifier that allows you to look up the phone number from your database. You would call Graphics.DrawString(phoneNumber, ...)
on the graphics from a new Bitmap
and save it to the Response.OutputStream
.
Something like this:
public class PhoneNumber : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var id = context.Request["id"];
var phoneNumber = "";
if (!string.IsNullOrEmpty(id))
{
phoneNumber = DataAccessor.GetPhoneNumber(id);
}
context.Response.ContentType = "image/png";
var bmp = new Bitmap(100, 20);
var gfx = Graphics.FromImage(bmp);
gfx.FillRectangle(Brushes.White, 0, 0, 100, 20);
gfx.DrawString(phoneNumber, new Font("Arial", 10), Brushes.Black, 0, 0);
bmp.Save(context.Response.OutputStream, ImageFormat.Png);
}
public bool IsReusable { get { return false; } }
}
Call it like:
<img src="PhoneNumber.ashx?id=<%# Eval("PhoneNumberId") %>" />