KEMBAR78
Web controls | PPT
ASP.NET Controls
Web controls?
Controls are small building blocks of the graphical
user interface, which include text boxes, buttons,
check boxes, list boxes, labels, and numerous other
tools. Using these tools, the 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, and data manipulation.
Server Controls
Web Controls
Four types of Web Controls
Intrinsic controls
List controls
Rich controls
Validation controls
Server Controls
Intrinisic Controls
Correspond to HTML controls
Supported controls
<asp:button>
<asp:imagebutton>
<asp:linkbutton>
<asp:hyperlink>
<asp:textbox>
<asp:checkbox>
 <asp:radiobutton>
 <asp:image>
 <asp:label>
 <asp:panel>
 <asp:table>
Server Controls
Intrinisic Controls
TextBox, ListControl, CheckBox and their
subclasses don’t automatically do a postback when
their controls are changed
Specify AutoPostBack=true to make change
events cause a postback
Server Controls
List Controls
Controls that handle repetition
Supported controls
 <asp:dropdownlist>
 <asp:listbox>
 <asp:radiobuttonlist>
 <asp:checkboxlist>
 <asp:repeater>
 <asp:datalist>
 <asp:datagrid>
Server Controls
CheckBoxList & RadioButtonList
Provides a collection of check box or
radio button controls
Can be populated via data binding
<asp:CheckBoxList id=Check1 runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
</asp:CheckBoxList>
Image control
TextBox control
DropDownList control
HyperLink control
RadioButtonList
Button control
WebControls3 Example
Server Controls
Rich Controls
Custom controls with rich functionality
Supported Controls
<asp:calendar>
<asp:adrotator>
Validation Controls
HTML does not facilitate validation of user input
ASP.NET provide validation controls that checks the
user input before submitting the form
Utilizes client-side DHTML to provide fast response
Validation Controls
RequiredFieldValidator
RangeValidator
CompareValidator
RegularExpressionvalidator
CustomValidator
ValidationSummary
Validation Controls
To activate the validation controls before the form is
submitted, set button property “Causes Validation” to
true
Each validation control is bound to one input control.
An input control may have multiple validation
controls
RequiredFieldValidator
initialValue
RangeValidator
MaximumValue, MinimumValue, Type
CompareValidator
ControlToCompare, Operator,Type, ValueToCompare
RegularExpressionvalidator
ValidationExpression
Displays all the errors that happened in the page in
one area
Message in the errorMessage properties will be
displayed in the summary
Display mode: list or bullet list or paragraph
Other properties
HeaderText
ShowMessageBox / ShowSummary
ASP.NET Page Life Cycle
When a page is requested, it is loaded into the server
memory, processed, and sent to the browser. Then it
is unloaded from the memory.
At each of these steps, methods and events are
available, which could be overridden according to the
need of the application.
The page life cycle phases are:
1. Initialization
2. Page load
3. Validation
4. Postback event handling
5. Page rendering
6. Unload
Following are the different stages of
an ASP.NET page:
1. Page request - When ASP.NET gets a page request, it
decides whether to parse and compile the page, or
there would be a cached version of the page;
accordingly the response is sent.
2. Starting of page life cycle - At this stage, the Request
and Response objects are set. If the request is an old
request or post back, the IsPostBack property of the
page is set to true. The UICulture property of the page
is also set.
Page initialization - At this stage, the controls on the
page are assigned unique ID by setting the UniqueID
property and the themes are applied. For a new
request, postback data is loaded and the control
properties are restored to the view-state values.
Page load - At this stage, control properties are set
using the view state and control state values.
Validation - Validate method of the validation control
is called and on its successful execution, the IsValid
property of the page is set to true.
Postback event handling - If the request is a postback
(old request), the related event handler is invoked.
Page rendering - At this stage, view state for the page
and all controls are saved. The page calls the Render
method for each control and the output of rendering
is written to the OutputStream class of the Response
property of page.
Unload - The rendered page is sent to the client and
page properties, such as Response and Request, are
unloaded and all cleanup done.

Web controls

  • 1.
  • 2.
    Web controls? Controls aresmall building blocks of the graphical user interface, which include text boxes, buttons, check boxes, list boxes, labels, and numerous other tools. Using these tools, the 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, and data manipulation.
  • 3.
    Server Controls Web Controls Fourtypes of Web Controls Intrinsic controls List controls Rich controls Validation controls
  • 4.
    Server Controls Intrinisic Controls Correspondto HTML controls Supported controls <asp:button> <asp:imagebutton> <asp:linkbutton> <asp:hyperlink> <asp:textbox> <asp:checkbox>  <asp:radiobutton>  <asp:image>  <asp:label>  <asp:panel>  <asp:table>
  • 5.
    Server Controls Intrinisic Controls TextBox,ListControl, CheckBox and their subclasses don’t automatically do a postback when their controls are changed Specify AutoPostBack=true to make change events cause a postback
  • 6.
    Server Controls List Controls Controlsthat handle repetition Supported controls  <asp:dropdownlist>  <asp:listbox>  <asp:radiobuttonlist>  <asp:checkboxlist>  <asp:repeater>  <asp:datalist>  <asp:datagrid>
  • 7.
    Server Controls CheckBoxList &RadioButtonList Provides a collection of check box or radio button controls Can be populated via data binding <asp:CheckBoxList id=Check1 runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> </asp:CheckBoxList>
  • 8.
    Image control TextBox control DropDownListcontrol HyperLink control RadioButtonList Button control WebControls3 Example
  • 9.
    Server Controls Rich Controls Customcontrols with rich functionality Supported Controls <asp:calendar> <asp:adrotator>
  • 10.
    Validation Controls HTML doesnot facilitate validation of user input ASP.NET provide validation controls that checks the user input before submitting the form Utilizes client-side DHTML to provide fast response
  • 11.
  • 12.
    Validation Controls To activatethe validation controls before the form is submitted, set button property “Causes Validation” to true Each validation control is bound to one input control. An input control may have multiple validation controls
  • 13.
  • 14.
    Displays all theerrors that happened in the page in one area Message in the errorMessage properties will be displayed in the summary Display mode: list or bullet list or paragraph Other properties HeaderText ShowMessageBox / ShowSummary
  • 15.
    ASP.NET Page LifeCycle When a page is requested, it is loaded into the server memory, processed, and sent to the browser. Then it is unloaded from the memory. At each of these steps, methods and events are available, which could be overridden according to the need of the application.
  • 16.
    The page lifecycle phases are: 1. Initialization 2. Page load 3. Validation 4. Postback event handling 5. Page rendering 6. Unload
  • 17.
    Following are thedifferent stages of an ASP.NET page: 1. Page request - When ASP.NET gets a page request, it decides whether to parse and compile the page, or there would be a cached version of the page; accordingly the response is sent. 2. Starting of page life cycle - At this stage, the Request and Response objects are set. If the request is an old request or post back, the IsPostBack property of the page is set to true. The UICulture property of the page is also set.
  • 18.
    Page initialization -At this stage, the controls on the page are assigned unique ID by setting the UniqueID property and the themes are applied. For a new request, postback data is loaded and the control properties are restored to the view-state values. Page load - At this stage, control properties are set using the view state and control state values. Validation - Validate method of the validation control is called and on its successful execution, the IsValid property of the page is set to true.
  • 19.
    Postback event handling- If the request is a postback (old request), the related event handler is invoked. Page rendering - At this stage, view state for the page and all controls are saved. The page calls the Render method for each control and the output of rendering is written to the OutputStream class of the Response property of page. Unload - The rendered page is sent to the client and page properties, such as Response and Request, are unloaded and all cleanup done.