Geeks With Blogs
Dennis Bottjer | MVP

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.

Posted on Monday, May 30, 2005 2:30 AM ASP.NET | Back to top

Comments on this post: Custom Server Controls vs. User Controls

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © DennisBottjer | Powered by: