User controls can greatly improve the maintainability of your site. Instead of repeating the same
markup and code on many different pages in your site, you encapsulate the code in a single control,
which you can then use in different areas of your site.
To improve the usefulness of your controls, you can add behavior to them. It’s common to create
controls with properties you can set in consuming pages, enabling you to change the behavior of the
control at run time. Although View State properties can solve some of the state issues you may come
across, you should carefully consider whether you really need them. Because these properties add to
the size of the page, they can have a negative impact on your site’s performance.
You can further improve the Banner control by keeping track of the number of times each image has
been clicked. The Planet Wrox site doesn’t implement this, but with the knowledge you gain in the
chapters about database interaction, this is easy to implement yourself.
In the next chapter you create another user control that serves as a contact form. By building the
form as a user control, it’s easy to ask your users for feedback from different locations in the site