Dennis Bottjer | ASP.NET + SharePoint Architect, Trainer & Speaker

"An Ounce of Prevention is Worth a Pound of Cure" - Ben Franklin
posts - 168, comments - 59, trackbacks - 41

My Links

News

Add to Technorati Favorites The views expressed in this blog are mine and mine alone, not that of my employer, Microsoft, or anyone else’s. No warrantee is given for the quality of any material on this site.

Tag Cloud

Archives

Post Categories

Custom Server Controls vs. User Controls

ASP.NET delivers on the promise of code re-use is through custom controls.  ASP.NET has given developer many new server side controls to work with such as the data grid, validation controls and the calendar control.  All of these controls expose properties to the developer that he/she can set at design time or through code at run time.  These controls have been designed to save developers much time by achieving what could only previously be accomplished in custom code.  Furthermore, ASP.NET allows developers to create  our own controls as either custom server controls or user controls.

As eluded to above controls are usually built in tools developers use to assemble an applications.  However, there are many reason why a developer may wish to build a custom control.  One such example is for validation purposes.  Perhaps, your application requires a text box for an entry field but you want to validate the users imput against some custom rules.  For example, maybe you want to have employees enter their employee number and make the text box validate that data.

Deciding to build a custom control and then what type of control to build is really a question of the scope of the intended re-use.  For example, user controls, identified by their extension of .ascx, are best used when re-use is only within the web application you are building.  Server Controls are built as a separate assembly and compile to a DLL.  Choosing to build a server control is a wise decision when the control can be shared by many applications.  Either way building a custom control is a good way to minimize code redundancy and provide a re-use mechanism for UI components.

Print | posted on Monday, May 30, 2005 2:30 AM | Filed Under [ ASP.NET ]

Comments have been closed on this topic.

Powered by: