O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required