Module 5
Module 5
NET Module 5
i. Information Tier:
➢ The information tier also called the bottom tier.
➢ It maintains the application’s data.
➢ This tier typically stores data in a relational
database management system.
Example: A retail store might have a database for
storing product information, such as descriptions,
prices and quantities in stock.
The same database also might contain customer
information, such as user names, billing addresses
and credit card numbers.
➢ This tier can contain multiple databases, which
together comprise the data needed for an
application.
Example: A business rule in the middle tier of a retail store’s web-based application might ensure that all
product quantities remain positive.
A client request to set a negative quantity in the bottom tier’s product information database would be rejected
by the middle tier’s business logic.
RequiredFieldValidator Control:
The RequiredFieldValidator control ensures that the required field is not empty. It is generally tied to a text box
to force input into the text box.
Syntax: <asp:RequiredFieldValidator ID="rfvcandidate"
runat="server" ControlToValidate ="ddlcandidate"
ErrorMessage="Please choose a candidate"
InitialValue="Please choose a candidate">
</asp:RequiredFieldValidator>
RangeValidator Control:
The RangeValidator control verifies that the input value falls within a predetermined range.
It has three specific properties:
Properties Description
It defines the type of the data. The available values are: Currency, Date,
Type
Double, Integer, and String.
MinimumValue It specifies the minimum value of the range.
MaximumValue It specifies the maximum value of the range.
CompareValidator Control:
The CompareValidator control compares a value in one control with a fixed value or a value in another control.
It has the following specific properties:
Properties Description
Type It specifies the data type.
ControlToCompare It specifies the value of the input control to compare with.
ValueToCompare It specifies the constant value to compare with.
It specifies the comparison operator, the available values are: Equal,
Operator NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual,
and DataTypeCheck.
Syntax:
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="CompareValidator">
</asp:CompareValidator>
RegularExpressionValidator:
The RegularExpressionValidator allows validating the input text by matching against a pattern of a regular
expression. The regular expression is set in the ValidationExpression property.
The following table summarizes the commonly used syntax constructs for
Regular expressions: \b, \n, \,\f, \r, \v, \t
Metacharacters: ., [abcd], [^abcd], [a-zA-Z], \w, \W, \s, \S, \d, \D
Quantifiers: *, +, ?, {n}, {n, }, {n,m}
Syntax:
<asp:RegularExpressionValidator ID="string" runat="server"
ErrorMessage="string" ValidationExpression="string"
ValidationGroup="string">
</asp:RegularExpressionValidator>
CustomValidator:
The CustomValidator control allows writing application specific custom validation routines for both the client
side and the server side validation.
➢ The client side validation is accomplished through the ClientValidationFunction property. The client
side validation routine should be written in a scripting language, such as JavaScript or VBScript, which
the browser can understand.
➢ The server side validation routine must be called from the control's ServerValidate eventhandler. The
server side validation routine should be written in any .Net language, like C# or VB.Net.
Syntax:
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction=.cvf_func.
ErrorMessage="CustomValidator">
</asp:CustomValidator>
ValidationSummary:
The ValidationSummary control does not perform any validation but shows a summary of all errors in the page.
The summary displays the values of the ErrorMessage property of all validation controls that failed validation.
The following two mutually inclusive properties list out the error message:
❖ ShowSummary : shows the error messages in specified format.
❖ ShowMessageBox : shows the error messages in a separate window.
Syntax:
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
DisplayMode = "BulletList" ShowSummary = "true"
HeaderText="Errors:" />
Validation Groups:
Complex pages have different groups of information provided in different panels. In such situation, a need might
arise for performing validation separately for separate group. This kind of situation is handled using validation
groups.
To create a validation group, you should put the input controls and the validation controls into the same logical
group by setting their ValidationGroup property.
Session Property:
Every Web Form includes a user-specific HttpSessionState object, which is accessible through property Session
of class Page. We use this property to manipulate the current user’s HttpSessionState object.
When a page is first requested, a unique HttpSessionState object is created by ASP.NET and assigned to the
Page’s Session property.
The session object is created from the HttpSessionState class, which defines a collection of session state items.
Properties Description
SessionID The unique session identifier.
The value of the session state item with the specified name. This is the default
Item(name)
property of the HttpSessionState class.
Count The number of items in the session state collection.
Gets and sets the amount of time, in minutes, allowed between requests before
TimeOut
the session-state provider terminates the session.
If you create an 'Ajax Enabled site' or add an 'AJAX Web Form' from the 'Add Item' dialog box, the web form
automatically contains the script manager control.
The ScriptManager control takes care of the client-side script for all the server side controls.
The following table shows the properties of the update panel control:
Properties Description
This property indicates whether the post backs are coming from the child
ChildrenAsTriggers
controls, which cause the update panel to refresh.
It is the content template and defines what appears in the update panel
ContentTemplate
when it is rendered.
RenderMode Shows the render modes. The available modes are Block and Inline.
UpdateMode Gets or sets the rendering mode by determining some conditions.
Defines the collection trigger objects each corresponding to an event
Triggers
causing the panel to refresh automatically.
Methods Description
Creates a Control object that acts as a container for child
CreateContentTemplateContainer
controls that define the UpdatePanel control's content.
Returns the collection of all controls that are contained in the
CreateControlCollection
UpdatePanel control.
Initializes the UpdatePanel control trigger collection if partial-
Initialize
page rendering is enabled.
Update Causes an update of the content of an UpdatePanel control.
The behavior of the update panel depends upon the values of the UpdateMode property and ChildrenAsTriggers
property.
UpdateMode ChildrenAsTriggers Effect
Always False Illegal parameters.
UpdatePanel refreshes if whole page refreshes or a
Always True
child control on it posts back.
UpdatePanel refreshes if whole page refreshes or a
Conditional False
triggering control outside it initiates a refresh.
UpdatePanel refreshes if whole page refreshes or a
Conditional True child control on it posts back or a triggering control
outside it initiates a refresh.
<ProgressTemplate>
Loading...
</ProgressTemplate>
</asp:UpdateProgress>
The above snippet shows a simple message within the ProgressTemplate tag.
However, it could be an image or other relevant controls. The UpdateProgress control displays for every
asynchronous postback unless it is assigned to a single update panel using the AssociatedUpdatePanelID
property.
ii. Placing a timercontrol directly inside the UpdatePanel to act as a child control trigger. A single timer
can be the trigger for multiple UpdatePanels.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000"> </asp:Timer>
<asp:Label ID="Label1" runat="server" Height="101px" style="width:304px">
</asp:Label>
</ContentTemplate>
</asp:UpdatePanel>