Lesson 2 For
Lesson 2 For
CHAPTER 2: OBJECTIVES
ASP.NET Web Forms Label
ASP.NET Web Forms TextBox
ASP.NET Web Forms Button
ASP.NET Web Forms HyperLink
ASP.NET Web Forms RadioButton
ASP.NET Web Forms Calendar
ASP.NET Web Forms CheckBox
ASP.NET Validation Controls
ASP.NET provides web forms controls that are used to create HTML components. These
controls are categories as server and client based. The following table contains the server
controls for the web forms.
This control is used to display printed information on the web forms. It is mainly used to create
caption for the other controls like: textbox.
To create label either we can write code or use the drag and drop capacity of visual studio .
This is server side control, asp provides own tag to create label. The example is given below.
< asp:LabelID="Label1" runat="server" Text="Label" ></asp:Label>
This control has its own properties that are tabled below.
This control has its own properties that are tabled below.
This control is used to perform events. It is also used to submit client request to the server. To
create Button either we can write code or use the drag and drop facility of visual studio IDE.
This is a server side control and asp provides own tag to create it. The example is given below.
< asp:ButtonID="Button1" runat="server" Text="Submit" BorderStyle="Solid" ToolTip="Submit"/>
This control has its own properties that are tabled below.
It is a control that is used to create a hyperlink. It responds to a click event. We can use it to refer
any web page on the server.
To create HyperLink either we can write code or use the drag and drop ability of visual studio
IDE. This control is listed in the toolbox.
This is a server side control and ASP.NET provides own tag to create it. The example is given
below.
< asp:HyperLinkID="HyperLink1" runat="server" Text="JavaTpoint" NavigateUrl=“default.aspx" ></asp:HyperLink>
This control has its own properties that are tabled below.
It is an input control which is used to takes input from the user. It allows user to select a choice
from the group of choices.
To create RadioButton we can drag it from the toolbox of visual studio.
This is a server side control and ASP.NET provides own tag to create it. The example is given
below.
< asp:RadioButtonID="RadioButton1" runat="server" Text="Male" GroupName="gender"/>
This control has its own properties that are tabled below.
It is used to display selectable date in a calendar. It also shows data associated with specific date.
This control displays a calendar through which users can move to any day in any year.
We can also set Selected Date property that shows specified date in the calendar.
To create Calendar we can drag it from the toolbox of visual studio.
This is a server side control and ASP.NET provides own tag to create it. The example is given
below.
< asp:CalendarID="Calendar1" runat="server"
SelectedDate="2017-06-15" ></asp:Calendar>
This control has its own properties that are tabled below.
ASP.NET Validation server controls allow you to easily validate any data a user has entered in a
Web form.
Validation controls allow you to completely customize the way error messages are displayed to
users when data values don’t pass validation.
ASP.NET Validation Control Types
Validation controls will only validate input with a subset of ASP.NET server controls.
these controls will be more than basic to validate all user input.
The controls that can have their input validated by ASP.NET’s Validation controls are
TextBox
ListBox
DropDownList
RadioButtonList
All Validation controls share similar properties. At a minimum, each control should specify two
properties (not including runat=”server”).First, they all must contain the ControlToValidate
property, which specifies the name of the server control that this validator must watch over.
Second, each control must have an ErrorMessage property that tells ASP.NET what message to
display to the user if the validation fails. There are a few additional properties.
CompareValidator Control
The CompareValidator control compares a value in one control with a fixed value or a value in
another control.
<asp:CompareValidator runat=”server”
ControlToValidate=”tbFName”
ControlToCompare=”tbLName”
Type=”String”
Operator=”NotEqual”
Display=”dynamic” />
The Range Validator control validates that the input value falls within a determined range.
</asp:RangeValidator>
RegularExpressionValidator
<asp:RegularExpressionValidator ID="remail"
runat="server" ControlToValidate="txtemail"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"> </asp:RegularExpressionValidator>
Validation Summary
The Validation Summary 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:
Show Summary: shows the error messages in specified format.
ShowMessageBox: shows the error messages in a separate window.
The syntax for the control is as given:
THE END