Control Class
Defines the properties, methods, and events that are shared by all ASP.NET server controls.
Assembly: System.Web (in System.Web.dll)
[BindableAttribute(true)] [ThemeableAttribute(false)] [AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] [AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class Control : IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor
This is the primary class that you derive from when you develop custom ASP.NET server controls. Control does not have any user interface (UI) specific features. If you are authoring a control that does not have a UI, or combines other controls that render their own UI, derive from Control. If you are authoring a control that does have a UI, derive from WebControl or any control in the System.Web.UI.WebControls namespace that provides an appropriate starting point for your custom control.
The Control class is the base class for all ASP.NET server controls, including custom controls, user controls, and pages. ASP.NET pages are instances of the Page class, which inherits from the Control class, and that handle requests for files that have an .aspx extension.
The Control class can directly or indirectly be used as part of the user interface for your Web application, and as such should be scrutinized to make sure best practices for writing secure code and securing applications are followed.
For general information on these topics, see Overview of Web Application Security Threats, Security Policy Best Practices, and Key Security Concepts. For more specific information, see Securing Standard Controls, How to: Display Safe Error Messages, How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings, and Introduction to the Validation Controls.
The following example demonstrates a custom server control that derives from the Control class. The InnerContent class overrides the Control::Render method, checks to see if the class has any child controls on the page and determines whether the first child of the control is a literal control. If both of these conditions are met, the overridden method writes the HTML string <H2>Your Message:, the contents of the literal control, and a closing </H2> tag to the Web Forms page.
Security Note: |
|---|
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview. |
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.Web.UI::Control
System.Web.UI::BasePartialCachingControl
System.Web.UI::DataBoundLiteralControl
System.Web.UI::DataSourceControl
System.Web.UI::DesignerDataBoundLiteralControl
System.Web.UI::ExtenderControl
System.Web.UI::HierarchicalDataSourceControl
System.Web.UI.HtmlControls::HtmlControl
System.Web.UI::LiteralControl
System.Web.UI.MobileControls::DeviceSpecific
System.Web.UI.MobileControls::MobileControl
System.Web.UI::ScriptManager
System.Web.UI::ScriptManagerProxy
System.Web.UI::TemplateControl
System.Web.UI::Timer
System.Web.UI::UpdatePanel
System.Web.UI::UpdateProgress
System.Web.UI.WebControls::Content
System.Web.UI.WebControls::ContentPlaceHolder
System.Web.UI.WebControls::DataPager
System.Web.UI.WebControls::DataPagerFieldItem
System.Web.UI.WebControls::HiddenField
System.Web.UI.WebControls::ListViewItem
System.Web.UI.WebControls::Literal
System.Web.UI.WebControls::LoginView
System.Web.UI.WebControls::MenuItemTemplateContainer
System.Web.UI.WebControls::MultiView
System.Web.UI.WebControls::PlaceHolder
System.Web.UI.WebControls::Repeater
System.Web.UI.WebControls::RepeaterItem
System.Web.UI.WebControls::Substitution
System.Web.UI.WebControls::View
System.Web.UI.WebControls::WebControl
System.Web.UI.WebControls.WebParts::ProxyWebPartManager
System.Web.UI.WebControls.WebParts::WebPartManager
System.Web.UI.WebControls::Xml
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Security Note: