2. 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.
4. 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>
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
Controls that 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>
10. 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
12. 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
14. 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
15. 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.
17. 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.
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.