This is the first of what will probably be a never ending series in creating web custom controls for ASP.Net using the 1.1 framework.
I have been built many controls over the last year and have come across many problems while trying to achieve a good result not only at run-time, but also design-time. If you have ever tried to create a web custom control, you will know what I am talking about.
While searching for answers to some of my questions in weblogs, forums and message boards, I found that there are hundreds (probably more like thousands) of people out there that have hit the same walls as I have. At one stage I was reading a weblog of a someone who is a Microsoft author in this subject, and I was astounded that even they couldn't answer the same questions as I have when posted by other people through the blogs comments.
Anyway, on with the show.
Firstly, a little overview about ASP.Net controls. There are several types of controls that you can build and use. How you created a web control will start with this question. What type of control is appropriate for the desired outcome?
The first type of web control is a web user control, which is a little like an ASP page in an ASP page. It has a variant of the aspx page for the XML state of the control and has the same event model and a code-behind page to run the control, but has an ascx file extension. It is compiled into the web sites assembly and can contains controls that you can drag and drop onto it from the toolbox and any other literal HTML you want. The two main problems with web user controls are that there is no design-time rendering as you just get a grey box, and they are not easily migrated between different web projects. I do however use these controls a lot, mainly for repeated items within a web project that have no relevance to any other web project.
The second type of web control is a web custom control. It doesn't have an XML view where you can change its HTML makeup. It can however have very good design-time rendering and is compiled into its own assembly. This means that the same assembly can be used across multiple web projects very easily.
These following articles will focus on web custom controls as they are much more complex that web user controls. I will cover many areas regarding creating web custom controls, as well as some interesting JavaScripts that I have created that are useful for enhancing the controls when rendered on the client.
If you haven't yet created any web custom controls, then start playing. The best way to learn most of this topic is to just do it yourself. Reading these articles will help overcome some of the more difficult issues with creating web custom controls, but they will assume a good knowledge of ASP.Net programming.