Saturday, 25 October 2014

ASP.NET - Server Controls

Controls are small building blocks of the graphical user interface, which includes text boxes, buttons, check boxes, list boxes, labels and numerous other tools, using which users can enter data, make selections and indicate their preferences.
Controls are also used for structural jobs, like validation, data access, security, creating master pages, data manipulation.
ASP.Net uses five types of web controls, which are:
  • HTML controls
  • HTML Server controls
  • ASP.Net Server controls
  • ASP.Net Ajax Server controls
  • User controls and custom controls
ASP.Net server controls are the primary controls used in ASP.Net. These controls again could be grouped into the following categories:
  • Validation controls - these are used to validate user input and work by running client-side script
  • Data source controls - these controls provides data binding to different data sources
  • Data view controls - these are various lists and tables, which can bind to data from data sources for display
  • Personalization controls - these are used for personalization of a page according to the user's preference, based on user information
  • Login and security controls - these controls provide user authentication
  • Master pages - these provides consistent layout and interface throughout the application
  • Navigation controls - these helps in navigation, for example, the menus, tree view etc.
  • Rich controls - these implements special features, for example, AdRotator control, FileUpload control, Calendar control etc.
The basic syntax for using server controls is:
<asp:controlType  ID ="ControlID"
                     runat="server"
                     Property1=value1  [Property2=value2] />
However, visual studio has the following features, which helps in error free coding:
  • Dragging and dropping of controls in design view
  • IntelliSense feature that displays and auto-completes the properties
  • The properties window to set the property values directly
Properties of the Server Controls
The ASP.Net server controls with a visual aspect are derived from the WebControl class and inherit all the properties, events and methods of this class.
The WebControl class itself and some other server controls that are not visually rendered, e.g., the PlaceHolder control or XML control etc., are derived from the System.Web.UI.Control class.
ASP.Net server controls inherit all properties, events and methods of the WebControl and System.Web.UI.Control class.
The following table shows the inherited properties, which are common to all server controls:

Property
Description
AccessKey
Pressing this key with the Alt key moves focus to the control
Attributes
It's the collection of arbitrary attributes (for rendering only) that do not correspond to properties on the control.
BackColor
Background colour.
BindingContainer
The control that contains this control's data binding.
BorderColor
Border colour.
BorderStyle
Border style.
BorderWidth
Border width.
CausesValidation
Indicates if it causes validation.
ChildControlCreated
It indicates whether the server control's child controls have been created.
ClientID
Control ID for HTML markup.
Context
The HttpContext object associated with the server control.
Controls
Collection of all controls contained within the control
ControlStyle
The style of the Web server control.
CssClass
CSS class
DataItemContainer
Gets a reference to the naming container if the naming container implements IDataItemContainer.
DataKeysContainer
Gets a reference to the naming container if the naming container implements IDataKeysControl.
DesignMode
It indicates whether the control is being used on a design surface.
DisabledCssClass
Gets or sets the CSS class to apply to the rendered HTML element when the control is disabled.
Enabled
Indicates whether the control is grayed out
EnableTheming
Indicates whether theming applies to the control.
EnableViewState
Indicates whether the view state of the control is maintained.
Events
Gets a list of event handler delegates for the control.
Font
Font .
Forecolor
Foreground colour.
HasAttributes
Indicates whether the control has attributes set.
HasChildViewState
indicates whether the current server control's child controls have any saved view-state settings.
Height
Height in pixels or %.
ID
Identifier for the control.
IsChildControlStateCleared
Indicates whether controls contained within this control have control state.
IsEnabled
Gets a value indicating whether the control is enabled
IsTrackingViewState
It indicates whether the server control is saving changes to its view state.
IsViewStateEnabled
It indicates whether view state is enabled for this control.
LoadViewStateById
It indicates whether the control participates in loading its view state by ID instead of index.
Page
Page containing the control.
Parent
Parent control.
RenderingCompatibility
It specifies the ASP.NET version that rendered HTML will be compatible with.
Site
The container that hosts the current control when rendered on a design surface.
SkinID
Gets or sets the skin to apply to the control. (
Style
Gets a collection of text attributes that will be rendered as a style attribute on the outer tag of the Web server control.
TabIndex
Gets or sets the tab index of the Web server control.
TagKey
Gets the HtmlTextWriterTag value that corresponds to this Web server control.
TagName
Gets the name of the control tag.
TemplateControl
The template that contains this control.
TemplateSourceDirectory
Gets the virtual directory of the Page or control containing this control.
ToolTip
Gets or sets the text displayed when the mouse pointer hovers over the Web server control.
UniqueID
Unique identifier
ViewState
Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.
ViewStateIgnoreCase
It indicates whether the StateBag object is case-insensitive.
ViewStateMode
Gets or sets the view-state mode of this control.
Visible
It indicates whether a server control is visible.
Width
Gets or sets the width of the Web server control.

No comments:

Post a Comment