System.Web.UI.UserControl Class

Represents an .ascx file, also known as a user control, requested from a server that hosts an ASP.NET Web application. The file must be called from a Web Forms page or a parser error will occur.

See Also: UserControl Members


[System.ComponentModel.Designer("Microsoft.VisualStudio.Web.WebForms.WebFormDesigner, Microsoft.VisualStudio.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.ComponentModel.Design.IRootDesigner))]
[System.ComponentModel.Designer("System.Web.UI.Design.UserControlDesigner, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.ComponentModel.Design.IDesigner))]
public class UserControl : TemplateControl, IAttributeAccessor, IUserControlDesignerAccessor


The System.Web.UI.UserControl class is associated with files that have .ascx extensions. These files are compiled at run time as System.Web.UI.UserControl objects and cached in server memory.

You can nest user controls by declaring one .ascx file in another including the latter in a Web Forms page.

User controls are contained in ASP.NET Web Forms pages, and offer Web developers an easy way to capture commonly used Web UI. They are instantiated and cached in ways similar to System.Web.UI.Page objects. Unlike pages, however, user controls cannot be called independently. They can only be called from the page or other user control that contains them.

Derive from this class if you want to create a user control using the code-behind technique. This is recommended if you are developing Web Forms pages using this technique.

For information about creating user controls declaratively, see Web Forms User Controls.


Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,