What Is an ASP.NET User CONTROL?

If you have been dabbling in ASP.NET for any time, you have probably heard myriad definitions for a "user control." Why not add one more to the list? An ASP.NET user control is a group of one or more server controls or static HTML elements that encapsulate a piece of functionality. A user control could simply be an extension of the functionality of an existing server control(s) (such as an image control that can be rotated or a calendar control that stores the date in a text box). Or, it could consist of several elements that work and interact together to get a job done (such as several controls grouped together that gather information about a user's previous work experience).

ASP NET CONTROL
In either case, a user control typically resides on a page with other elements. This breakup of functionality could be the basis of an entire application built with independent and reusable user controls. The controls could then be dynamically loaded into different areas of the page. Microsoft has released the sample IBuySpy application to illustrate this architecture. The IBuySpy application can be located at www.ibuyspy.com.

With this methodology in mind, you may be asking yourself what is the difference between ASP.NET user controls and simply embedding other pages on the page? Couldn't we do that in ASP 3.0? The power comes from the framework treating the user controls as a standalone object. By exposing properties of the control through the code-behind (or in the HTML), other elements can interact with the user control programmatically and with ease. While replicating this functionality is possible in ASP 3.0, it was quite a troublesome task. Now with user controls being treated as objects, we can get and set values such as mode, size, behavior dictation, and colors with relative ease.
ASP NET CONTROL
Categories: