ASP.NET Developer's Cookbook - Chapter 3: Custom Controls | CodeGuru

ASP.NET Developer’s Cookbook – Chapter 3: Custom Controls

3.0. Introduction One of the most powerful features of ASP.NET is its support for custom server controls and components. ASP.NET ships with dozens of built-in controls, and developers can easily extend these controls or write their own controls from scratch. Server controls can be used to encapsulate complex user interface logic or business rules, and […]

Written By
CodeGuru Staff
CodeGuru Staff
Sep 5, 2003
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

3.0. Introduction

One of the most powerful features of ASP.NET is its support for custom server controls and components. ASP.NET ships with dozens of built-in controls, and developers can easily extend these controls or write their own controls from scratch. Server controls can be used to encapsulate complex user interface logic or business rules, and can benefit from design-time support like drag-and-drop and toolbox support and property builders. Custom controls pick up where User Controls leave off, providing greater flexibility, reusability, and a better design time experience, but with some added complexity. In this chapter you will find examples covering some of the most common server-control techniques.

Custom controls as a rule inherit directly or indirectly from the System.Web.UI.Control base class. Controls that are visible on a page should inherit directly or indirectly from System.Web.UI.WebControls.WebControl, which provides properties like Style, which you can use to determine the look of the control on the page. Custom controls can be built in a number of ways. Some simply override the Render() method, thus determining the HTML output in place of the control at runtime. Others, known as composite controls, act as containers for other controls. Others inherit from existing fully functional controls to create more specific versions of these controls or to enhance their functionality.

Controls in ASP.NET can support data-binding as well as templates. In fact, there is easily enough information about building controls to fill an entire book (and in fact such a book exists and is listed at the end of this section), so this chapter attempts to cover the most common techniques that you will use, leaving much of the theory to other books dedicated to control building.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.