DekGenius.com
[ Team LiB ] Previous Section Next Section

WebControldisposable

System.Web.UI.WebControls (system.web.dll)class

This class is the base class for all web controls. The WebControl class derives much of its basic functionality from System.Web.UI.Control, including functionality for data binding and using view state. The WebControl class adds additional user-interface specific members for configuring the control's appearance—including a collection of CSS attributes (Style), color options (BackColor and ForeColor), a shortcut key (AccessKey), and various border style, font, and dimension properties. One interesting property that is specific to web controls is CssClass, which sets the Cascading Style Sheet class applied to the control. This is rendered as the class attribute in HTML (for example, <input type=text class="class1" style="ForeColor:red">). Some properties, such as AccessKey, may not be supported on down-level browsers.

All methods and the TagName, TagKey, Attributes, and Style properties are provided for developers to use or override in custom web controls. If you want to create a server control that renders user interface (HTML), you should extend one of the web control classes or inherit directly from WebControl rather than the more basic System.Web.UI.Control class. You should override the RenderContents( ) method, which provides a System.Web.UI.HtmlTextWriter for generating output. You do not need to manually output style attributes (or the basic HTML tag, if you have supplied it to the base WebControl constructor), as the WebControl class will handle these details automatically. Alternatively, you can override Render( ) for more fine-grained control. You may also want to implement the interfaces System.Web.UI.IPostBackDataHandler and System.Web.UI.IPostBackEventHandler to allow the control to retrieve postback data and fire events on postback.

public class WebControl : System.Web.UI.Control, System.Web.UI.IAttributeAccessor {
// Public Constructors
   public WebControl(System.Web.UI.HtmlTextWriterTag tag);
// Protected Constructors
   protected WebControl( );
   protected WebControl(string tag);
// Public Instance Properties
   public virtual string AccessKey{set; get; }
   public AttributeCollection Attributes{get; }
   public virtual Color BackColor{set; get; }
   public virtual Color BorderColor{set; get; }
   public virtual BorderStyle BorderStyle{set; get; }
   public virtual Unit BorderWidth{set; get; }
   public Style ControlStyle{get; }
   public bool ControlStyleCreated{get; }
   public virtual string CssClass{set; get; }
   public virtual bool Enabled{set; get; }
   public virtual FontInfo Font{get; }
   public virtual Color ForeColor{set; get; }
   public virtual Unit Height{set; get; }
   public CssStyleCollection Style{get; }
   public virtual short TabIndex{set; get; }
   public virtual string ToolTip{set; get; }
   public virtual Unit Width{set; get; }
// Protected Instance Properties
   protected virtual HtmlTextWriterTag TagKey{get; }
   protected virtual string TagName{get; }
// Public Instance Methods
   public void ApplyStyle(Style s);
   public void CopyBaseAttributes(WebControl controlSrc);
   public void MergeStyle(Style s);
   public virtual void RenderBeginTag(System.Web.UI.HtmlTextWriter writer);
   public virtual void RenderEndTag(System.Web.UI.HtmlTextWriter writer);
// Protected Instance Methods
   protected virtual void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer);
   protected virtual Style CreateControlStyle( );
   protected override void LoadViewState(object savedState);    // overrides System.Web.UI.Control
   protected override void Render(System.Web.UI.HtmlTextWriter writer); // overrides System.Web.UI.Control
   protected virtual void RenderContents(System.Web.UI.HtmlTextWriter writer);
   protected override object SaveViewState( );                    // overrides System.Web.UI.Control
   protected override void TrackViewState( );                     // overrides System.Web.UI.Control
}

Hierarchy

System.Object System.Web.UI.Control(System.ComponentModel.IComponent, System.IDisposable, System.Web.UI.IParserAccessor, System.Web.UI.IDataBindingsAccessor) WebControl(System.Web.UI.IAttributeAccessor)

Subclasses

Multiple types

Passed To

System.Web.UI.MobileControls.Style.ApplyTo( ), RepeatInfo.RenderRepeater( ), Style.AddAttributesToRender( )

    [ Team LiB ] Previous Section Next Section