Wednesday, April 13, 2005

Choose Your Own Adventure

I haven't received many comments on what the community would like the topic of my May presentation to be. I am leaning toward the "Custom Web Controls Everywhere" presentation.

Here's a more detailed description of the presentation. Please feel free to comment on this before the presentation.


The emphasis of the presentation would be on why developers should create inherited controls for nearly all asp.net controls. This will differ from the many articles I've read that describe creating custom controls, only if additional functionality needs to be implemented.

Some of the specific controls that I would be focusing on are:

  • DataGrid
  • TextBox
  • DropDownList
  • Checkbox
  • RadioButton
  • Button
  • LinkButton
  • Hyperlink

By implementing custom controls "everywhere", development standards are easier to enforce, as developers on the team have fewer opportunities for mistakes. This produces a more consistent user interface that can be easily modified if needed.

The presentation will describe situations where I've seen developers (including
myself) wish that a custom control had been implemented early on, because a change needs to be applied site-wide. One example of this is how multiple levels of inherited textboxes can allow for new business rules to be implemented quickly, as part of a specialized textbox server control.

I also plan on including a short discussion on how this approach will alter slightly with ASP.NET 2.0's skinning. I will point out however, that skinning is not an alternative to creating custom controls, but more of a compliment to the approach.

2 comments:

Jay said...

I think the 'create custom controls' is an excellent topic and one that is not often covered. I'm intrigued by the thought of somehow applying business rules at some level in the custom class.

The 'skinning' topic would be useful for those who plan to jump to ASP.NET 2.0 soon. If possible cover the points in your 'prepared' presentation.

I'm not in Cincinnati so I hope you'll be posting the presentation shortly thereafter.

Jeff Handley said...

Hi Jay,

I have posted the presentation materials here on my blog. I hope that you find the information helpful.

I don't believe anything in the presentation directly addresses the business rules stuff, as I mainly covered that verbally.

However, what I discussed was when you need to enforce data entry rules for certain "types" of fields. An example could be entering a date that must be a business day. One could create a custom TextBox control that includes a custom ASP.NET validator. The ASP.NET validator could do the work of ensuring that the date entered is a business day.

By wrapping the textbox and the validator together in a custom BusinessDayTextBox control, this logic could be built once and reused across the entire application very easily.

The presentation materials includes a sample application framework. The framework was created in ASP.NET 2.0, and then a 1.x version was also created. This shows the differences between the 2 versions of ASP.NET.

I emphasized that skinning/theming will not replace using "Custom Web Controls Everywhere!", but instead this will be a good compliment to the concept, allowing you to extract the presentation rules from the custom control code.

Thanks for the interest and let me know if you have any questions or comments on the materials.

-Jeff