The output caching directive enables caching.
Custom Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. Can be used by Multiple Applications (If Shared Dlls), Even if Private can copy to bin directory of web application add reference and use. Normally designed to provide common functionality independent of consuming Application.
User Controls are similar to those of ASP include files, easy to create, can not be placed in the toolbox and dragged – dropped from it. A User Control is shared among the single application files.
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).
User Controls: We need to implement with Predefined Functionality with Available Properties
Web User Controls:Web User Controls Implements Customized Properties and Customized Methods,we can develop any control with User defined Properties
Declare the @ Register directive.
For example, use the following code.
<%@ Register TagPrefix=”UC” TagName=”TestControl” Src=”test.ascx” %>
When a page with a user control is requested, the following occurs:
1)The page parser parses the .ascx file specified in the Src attribute in the @ Register directive and generates a class that derives from the System.Web.UI.UserControl class.
2)The parser then dynamically compiles the class into an assembly.
If you are using Visual Studio, then at design time only, Visual Studio creates a code behind file for the user control, and the file is precompiled by the designer itself.
3)Finally, the class for the user control, which is generated through the process of dynamic code generation and compilation, includes the code for the code behind file (.ascx.cs) as well as the code written inside the .ascx file.
The Sequence of User controls Execution as follows.
OnInit of the user control
OnInit of the containing page
OnLoad of the containing page
OnLoad of the user control