Of course, because ASP.NET's Page
infrastructure is set up this way, it leaves the door open for custom User
controls. In this tutorial we looked at rendered custom controls. Custom controls that render have the ability to squirt anything they want into the output bound for the browser. Custom rendered controls usually manage a set of properties, fire events to their hosts, and render snapshots of themselves to their hosts. In this tutorial we built a palindrome checker as an example. Next, we'll see examples of the other kind of custom control-composite-style controls.
Tutorial 4 Quick Reference
How to create a custom control that takes over the rendering process
Derive a class from
System.Web.UI.Control
Override the Render method
Visual Studio includes a project type, Web Custom Control, that fits the bill
How to Add a custom control to the toolbox
Show the toolbox if it's not already showing by selecting
View | Toolbox
from the main menuRight mouse click anywhere in the toolbox
Select Choose Items from the local menu
Choose a control from the list
OR
Browse to the assembly containing the control
How to Change the properties of controls on a page
Make sure the page editor is in Designer mode
Highlight the control whose property you want to change
Select the property to edit in the property window
How to Store view state information that lives beyond the scope of the page
Use the ViewState property of the control
It's a name/value dictionary that contains serializable types
Just be sure to use the same index to retrieve the information as you do to store the information
How to Write browser version-independent rendering code
Use the
HtmlTextWriter
tag-rendering methods for specific tags instead of hard-coding them. The Render method will have the correct HtmlTextWriter based on header information coming down from the browser.