Dynamically Generate an Image on Part of a Page

Problem

You want to create a page that combines a dynamically generated image and ordinary Web controls.

Solution

Put the code that generates the dynamic image in a separate page, and create an <img> tag that references the page.

Discussion

The easiest way to use dynamically generated images with ASP.NET is to write them directly to the response stream. This means that a page that uses a dynamically generated image can’t also use Web controls. One way to circumvent this problem is to create a full-blown custom Web control. Another, simpler option is to use an ordinary HTML <img> tag that references the form that generates the dynamic image.

Figure 15-13 shows one example. On the left are several Web controls ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.