Roadmap › Custom Controls & Reusable UI Components in .NET — Web Forms to Blazor › Module: Web Forms Controls
Lessons in this course (9)
1. User controls vs custom server controls
Basic★ Must knowLesson 1 of 9
User control (.ascx) | Custom server control (class) | |
|---|---|---|
| Built with | Markup + code-behind (designer support) | Code only (C#/VB), renders its own HTML |
| Reuse | Within one web application (needs the .ascx file) | Across applications (compiled DLL), Toolbox support |
| Effort | Low | Higher |
| Design-time | Basic | Rich (designers, smart tags, property grid) |
| Registration | <%@ Register Src="~/Controls/X.ascx" TagPrefix="uc" TagName="X" %> | <%@ Register Assembly="Shop.Controls" Namespace="Shop.Controls" TagPrefix="shop" %> or web.config <controls> |
| Example | Address editor, login box for this site | Reusable <shop:Money> label, rating control sold to many projects |
User controls were covered in the Web Forms course; here we build custom controls.