asp.net.ph

Skip Navigation Links

Introducing Web Forms User Controls

ASP.NET Web Forms   Web Forms Server Controls   Web Forms User Controls


The Web Forms User Control is a Web Forms page that you can use as a control on another page. User controls provide an easy way to design and reuse common UI functionality across a Web application, including:

  • Menus
  • Toolbars

Because user controls are just modified Web Forms pages, you can use many of the same tools and coding techniques that you use for standalone Web Forms pages. In addition, you can convert existing Web Forms pages to use as controls.

User controls can be written in any .NET language, and can be used on any Web Forms page, regardless of what .NET language you are using to create the page.

User Control Structure

A Web Forms user control is a complete Web Forms page with both user interface page and code-behind file. The user interface page differs from an .aspx file in these ways:

  • The extension must be .ascx.
  • The user control does not have <HTML>, <BODY>, and <FORM> elements in it.

In every other way, a user control is like a Web Forms page. You can use the same HTML elements and Web controls on a user control that you do on a standard Web Forms page. For example, if you are creating a user control to use as a toolbar, you can drag a series of Button Web controls onto the control and create event-handling methods for the buttons.

User Control Object Model

As with any control, a Web Forms user controls supports not only a custom appearance, but its own object model. When creating the control, you can define properties, methods, and events associated with the control.



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note