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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.