Recently, we decided that we need to build a better server control for our navigation buckets. (We refer to our side navigation as buckets.) Building this control from scratch allowed me to better understand the way ASP.Net creates the page from controls. It also helped me to realize that I shouldn’t have to write all of this plumbing code to get one stupid control to work. Although the control is now working, we did run into a few problems. Remember, if you ever need to keep data do not replace it with Nothing. This is a bad thing is difficult to debug. Also, if you need data from an item cast it to the correct class. If you don’t more bad things will happen.
Overall, it wasn’t that bad if you have the right information. I suggest buy Deveoping Microsoft ASP.Net Server Controls and Components from MS Press. And don’t forget to download the source code. It is extremely helpful. Below are some articles I suggest that you digest and understand to build a better control.
Creating Web Server Control Templates Programmatically
Templated Data-Bound Control Sample
Creating Templates Dynamically in a DataList Web Server Control
Creating a Data Bound ListView Control
Implementing a Web Forms Data-Bound Control Designer
Implementing Dynamic ItemTemplates
Loading ASP.NET Templates Dynamically
Dynamic Templates for the Repeater, DataList and DataGrid Controls
Understanding Templates in ASP.NET
ASP.NET Controls Templates
Building Templated Custom ASP.NET Server Controls