Creating Custom Controls

You've seen how a user control can group together and extend existing Web Forms controls, and how to use adapters to take responsibility for the HTML that a control renders. But if you want to create an entirely new kind of element, then you need to create a custom server control.

Most of the time, user controls or control adapters will allow you to achieve the effect you require, so creating a server control is a pretty unusual thing to do.

In order to demonstrate the process of building a custom control, we will create one that neatly displays the results of the swimming calculation performed earlier in the chapter. This is something that could easily be done as a user control, but we'll do it as a server control instead. ...

Get Applied ASP.NET 4 in Context now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.