Saturday, 14 April 2012

What are Control,WebControl,and their derived types?

Contorl:

Control is base class for all controls of system.web.UI.webcontrols like standard controls,listcontrols,databound controls, validation controls…ect
Ex:
Visiable property is required for all controls.

Standard,Data controls,validation controls all inhirits this property form Control Class why because this funcationality required for all the controls.
Coming to events:

DataBinding,Disposed,Init,Load,PreRender,Unload are relavent to all the controls. So every controls has perform these events in particular like
Init(first step PLC)--Load—DataBinding—Prerender—Unload—Dispose(last step PLC)
These all events are performed implictly in page life cyle.If we want to customize these events.we have apporiate methods
Like OnInit,OnLoad,OnDataBinding,OnPreRender,OnUnload----events can be overrided in our page class.
Ex: Page,TempletControl,UserControl;

WebControl:

WebControl Serves as the base class that defines the methods, properties and events common to all controls in the System.Web.UI.WebControls namespace.which is the first class in system.web.ui.webcontrols namespace.

All Controls are webcontrols---standard,listcontrols,datacontrols…ect.
Ex:Label,TextBox,ListControls,DataBoundControl…..ect

Derived Types:

Here we have many categories

Standard Controls: Directly derived from WebControls.

ListControls : ListBox,RadioButtonList…are databinding controls…so we have base class is ListControl.
and ListControls Supports inhirits the DataBoundControl class so all Listcontrols get the Properties like


public abstract class ListControl : DataBoundControl, IEditableTextControl, ITextControl


        public ListControl();
        public virtual bool AppendDataBoundItems { get; set; }       
        public virtual bool AutoPostBack { get; set; }
        public virtual bool CausesValidation { get; set; }    
        public virtual string DataTextField { get; set; }    
        public virtual string DataTextFormatString { get; set; }     
        public virtual string DataValueField { get; set; }      
        public virtual ListItemCollection Items { get; }      
        public virtual int SelectedIndex { get; set; }      
        public virtual ListItem SelectedItem { get; }     
        public virtual string SelectedValue { get; set; } 
        protected override HtmlTextWriterTag TagKey { get; }      
        public virtual string Text { get; set; }    
        public virtual string ValidationGroup { get; set; }

     protected internal override void RenderContents(HtmlTextWriter writer);
     protected override object SaveViewState();
     protected void SetPostDataSelection(int selectedIndex);
     protected override void TrackViewState();
     public event EventHandler SelectedIndexChanged;
    

     public event EventHandler TextChanged;

}

Ex:

DropDownList1.DataSource=ds;                                    //   BaseDataBoundControl
DropDownList1.DataTextField=”CityId”,                     // DataBoundControl
DropDownList1.DataValueField=”CityName”;            // DataBoundControl
DrorpDownlist.DataBind();                                            //  BaseDataBoundControl:Control


but DataBoundCotnrol overrides the DataBind() method from Control class.

For all databound contols are derived from

BaseDataBoundControl.

public virtual object DataSource { get; set; }
public virtual string DataSourceID { get; set; }
public override void DataBind();
are common to all derived types.
'
DataBoundControl :

ListControls and CompositeControls are supporting databinding because of which implements DataBoundControl class. 

1.ListControl    2.CompositieBoundControl     3. HierarchicalDataBoundControl.

DataBoundControl---for all databound controls which display data in the form of List types and tabular type.

ListControl: DataBoundControl-------listtypes

RadioButtionList,DropDownList…ect

CompositeDataBoundControl:DataBoundControl---tabulartypes

GridView,FormView,LoginView…ect

HirerchicalDataBoundControl:BaseDataBoundControl---hirerchicaltypes

TreeView,Menu..ect

No comments:

Post a Comment