Dynamically Generate an Image on Part of a Page


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


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


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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.