Creating User Controls

Let’s start by building a simple User control that randomly displays one image from a folder of images (see Figure 7.1). The code for the User control is contained in Listing 7.1.

Figure 7.1. Displaying an image with the RandomImage User control.

image

Listing 7.1. RandomImage.ascx

images

images

Visual Web Developer Note

You create a new User control in Visual Web Developer by selecting website, Add New Item, and the Web User control ...

Get ASP.NET 4 Unleashed 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.