SlideShare a Scribd company logo
Chapter 3
Validation
Controls
ValidationControl ហ ោសូហនឿន 1
Introduction
 Used to validate User-Input in an input control.
 The page validation is performed when a
Button, ImageButton, or Link control is clicked.
 Setting CauseValidation to False is to cancel
Validation.
ValidationControlហ ោសូហនឿន
2
Types of Validation Controls
 There are 6 types of Validation Controls
 RequiredFiledValidator Control
 RangeValidator Control
 RegularExpressionValidator Control
 CompareValidator Control
 CustomValidator Control
 ValidationSummary Control
ValidationControlហ ោសូហនឿន
3
RequiredFieldValidator
 To make sure that has entered the required data in
the input control(TextBox).
<asp:RequiredFieldValidator runat=server ID=…
ControlToValidate=… ErrorMessage=“….">
</asp:RequiredFieldValidator>
ValidationControlហ ោសូហនឿន
4
RequiredFieldValidator
 See the example:
<body>
<form id="form1" runat="server">
<asp:TextBox ID=fName runat=server> </asp:TextBox>
<asp:RequiredFieldValidator runat=server ID=fNameVal
ControlToValidate=fName ErrorMessage="Please Enter the First
Name"></asp:RequiredFieldValidator>
<asp:Button ID=Submit runat=server Text=Submit />
</form>
</body>
ValidationControlហ ោសូហនឿន
5
RangeValidator
 To check that the values input is what in the
specified range of values.
 There are some important properties:
 ControlToValidate
 MinimumValue
 MaximumValue
 Type
<asp:RangeValidator runat=server ID=… ControlToValidate=… Type=…
MinimumValue=… MaximumValue=… ErrorMessage=“…">
</asp:RangeValidator>
ValidationControlហ ោសូហនឿន
6
RangeValidator
 See the Example:
<body>
<form id="form1" runat="server">
<asp:TextBox ID=fName runat=server> </asp:TextBox>
<asp:RangeValidator runat=server ControlToValidate=fName MinimumValue="A"
MaximumValue="Z" Type=String ID=fNameVal ErrorMessage="Capital Only"
CultureInvariantValues="True"></asp:RangeValidator> <br />
<asp:Button ID=Submit runat=server Text=Submit />
</form>
</body>
ValidationControlហ ោសូហនឿន
7
RegularExpspressionValidator
 To make sure the data input into the input box
match the specified the format.
 It is made up of text with an embedded code
started with a backslash ().
 The property ValidateExpression is used the
format the data input.
ValidationControlហ ោសូហនឿន
8
RegularExpspressionValidator
 To set the word boundary use
 b ….. b
 [Range of Input]
Example you can set the format for letter input a-z and A-Z as below:
b[A-Za-z]+b
<asp:TextBox ID=fName runat=server ></asp:TextBox>
<asp:RegularExpressionValidator runat=server ID=fNameVal ControlToValidate=fName
ValidationExpression="b[A-Z]+b" ErrorMessage="Enter the Letter [a-z, A-Z]
only"></asp:RegularExpressionValidator>
ValidationControlហ ោសូហនឿន
9
RegularExpspressionValidator
 There are some more important forms of the
expression format.
w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*
[0-9]{3}-[0-9]{6}
[0-9]{3}-[0-9]{6,7}
ValidationControlហ ោសូហនឿន
10
CompareValidator
 It is used to compare the value entered by a user
into an input box to another.
 Some properties used with the CompareValidator
are:
 ControlToCompare
 Operator
 ValueToCompare
 ControlToValidate
 Type
 ErrorMessage
ValidationControlហ ោសូហនឿន
11
CompareValidator
 The Operator property has the following value:
 Equal
 NotEqual
 GreaterThan
 GreaterThanEqual
 LessThan
 LessThanEqual
 DataTypeCheck
ValidationControlហ ោសូហនឿន
12
CompareValidator
 See the example:
<body>
<form id="form1" runat="server">
User Name: <asp:TextBox ID=txtuser runat=server > </asp:TextBox>
<asp:CompareValidator runat=server ControlToValidate=txtuser
ValueToCompare="sonoeun" ErrorMessage="Invalid User Name">
</asp:CompareValidator> <br />
<asp:Button runat=server ID=bntSubmit Text=Submit />
</form>
</body>
ValidationControlហ ោសូហនឿន
13
CustomValidator
 To check that the data input matches the a given
condition or not.
 It is a powerful way to use the Validator controls
since you can write your own customization code.
 It uses the main properties and methods as below:
 ClientValidationFunction: To set the name of the custom
client-side script function used for Validation.
 ValidateEmptyText: To set a boolean value to make sure if
the empty text should be validated or not.
 ServerValidate : The method occurring when the validation
takes place on the server.
ValidationControlហ ោសូហនឿន
14
CustomValidator
 See the Example
<body>
<form id="form1" runat="server">
<script language=vbscript runat=server type="text/vbscript" >
Sub serverVal(ByVal source, ByVal objServer)
If (objServer.value = "ServerValidation") Then
objServer.IsValid = True
lbl.Text = "Subscription Successful"
Else
objServer.IsValid = False
lbl.Text = "Subscription Not Successful"
End If
End Sub
</script>
ValidationControlហ ោសូហនឿន
15
CustomValidator
 See the Example (cont.)
<asp:TextBox ID=ServerObj runat=server ></asp:TextBox>
<asp:CustomValidator ID=ServerObjVal runat=server
OnServerValidate="serverVal" ControlToValidate=ServerObj
ErrorMessage="Subscription NOT Accepted">
</asp:CustomValidator>
<br />
<asp:Button runat=server ID=submitServer Text=Submit />
<br />
<asp:label ID=lbl runat=server ></asp:label>
</form>
</body>
ValidationControlហ ោសូហនឿន
16
ValidationSummary
 It collects all validation control error messages for
centralized display.
 It can be displayed as a list, a bullet list, a single
paragraph depending on the DisplayMode
 Specifying the summary display by setting
ShowSummary and ShowMessageBox
properties.
ValidationControlហ ោសូហនឿន
17
ValidationSummary
 Some properties you should know when you use
validationSummary are:
 DisplayedMode
 EnableClientScript
 ForeColor
 HeaderText
 ShowMessageBox
 ShowSummary
ValidationControlហ ោសូហនឿន
18
ValidationSummary
 See The Example:
<body>
<form id="form1" runat="server">
First Name:
<asp:TextBox ID=fName runat=server ></asp:TextBox>
<asp:RequiredFieldValidator runat=server ID=RefNameVal
ControlToValidate=fName ErrorMessage="First Name
Needed"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator runat=server ID=EprfNameVal
ControlToValidate=fName ValidationExpression="b[A-z]+b"
ErrorMessage="No Number Permited">
</asp:RegularExpressionValidator>
<br />
Last Name:
<asp:TextBox ID=lName runat=server></asp:TextBox>
ValidationControlហ ោសូហនឿន
19
ValidationSummary
 See The Example:
<asp:RequiredFieldValidator runat=server ID=RelNameVal
ControlToValidate=lName ErrorMessage="Last Name
Needed"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator runat=server ID=ExplNameVal
ValidationExpression="b[A-Z]+b" ControlToValidate=lName
ErrorMessage="Capital Letter Only">
</asp:RegularExpressionValidator> <br/>
<asp:Button runat=server ID=btnSubmit Text=Submit />
<br />
<asp:ValidationSummary ID=valSummary
ShowMessageBox=true runat=server />
</form>
</body>
ValidationControlហ ោសូហនឿន
20
ValidationGroup
 It a property of Validator controls.
 Setting ValidationGroup, it validates only the
validation controls within the specified group when
the control is post back to the server.
 It is used to assign a validation control to a
validation group.
ValidationControlហ ោសូហនឿន
21
ValidationGroup
 Example
ValidationControlហ ោសូហនឿន
22
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" Runat="server" ValidationGroup="First">
</asp:TextBox>
<asp:TextBox ID="TextBox2" Runat="server" ValidationGroup="First">
</asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server"
ValidationGroup="First" ErrorMessage="TextBox1 should not be blank"
ControlToValidate="TextBox1"> </asp:RequiredFieldValidator>
<asp:Button ID="Submit1" Runat="server" ValidationGroup="First"
Text="Submit 1" />
<br /> <br />
ValidationGroup
ValidationControlហ ោសូហនឿន
23
<asp:TextBox ID="TextBox3" Runat="server" ValidationGroup="Second">
</asp:TextBox>
<asp:TextBox ID="TextBox4" Runat="server" ValidationGroup="Second">
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server"
ErrorMessage=" TextBox3 should not be blank"
ControlToValidate="TextBox3" ValidationGroup="Second">
</asp:RequiredFieldValidator>
<asp:Button ID="Submit2" Runat="server" ValidationGroup="Second"
Text="Submit 2" />
</div>
</form>
</body>
End
ValidationControl ហ ោសូហនឿន 24

More Related Content

Similar to Chapter 3 (validation control)

Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
Guddu gupta
 
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptxvnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
YamunaS38
 
Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.net
Deep Patel
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
Shishir Jain
 
validation-controls.pdf ioue8n uoh souu o3i
validation-controls.pdf ioue8n uoh souu  o3ivalidation-controls.pdf ioue8n uoh souu  o3i
validation-controls.pdf ioue8n uoh souu o3i
CoRRexGaMing
 
Validation in asp.net
Validation in asp.netValidation in asp.net
Validation in asp.net
Sireesh K
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
KS Technologies Vadodara
 
Validation controls ppt
Validation controls pptValidation controls ppt
Validation controls pptIblesoft
 
Asp.net validation
Asp.net validationAsp.net validation
Asp.net validation
Paneliya Prince
 
validation
validationvalidation
validation
teach4uin
 
Web controls
Web controlsWeb controls
Web controls
Sarthak Varshney
 
validation & regular expression chacteristics
validation & regular expression chacteristicsvalidation & regular expression chacteristics
validation & regular expression chacteristics
L21IT131DRajkumar
 
Ajax control tool kit
Ajax control tool kitAjax control tool kit
Ajax control tool kitVidhi Patel
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
Ravi Bhadauria
 

Similar to Chapter 3 (validation control) (20)

2310 b 07
2310 b 072310 b 07
2310 b 07
 
Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
 
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptxvnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
 
Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.net
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
 
validation-controls.pdf ioue8n uoh souu o3i
validation-controls.pdf ioue8n uoh souu  o3ivalidation-controls.pdf ioue8n uoh souu  o3i
validation-controls.pdf ioue8n uoh souu o3i
 
Validation in asp.net
Validation in asp.netValidation in asp.net
Validation in asp.net
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
 
Validation controls ASP .NET
Validation controls ASP .NETValidation controls ASP .NET
Validation controls ASP .NET
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
Validation controls ppt
Validation controls pptValidation controls ppt
Validation controls ppt
 
Asp.net validation
Asp.net validationAsp.net validation
Asp.net validation
 
Visual studio 2008 asp net
Visual studio 2008 asp netVisual studio 2008 asp net
Visual studio 2008 asp net
 
validation
validationvalidation
validation
 
Web controls
Web controlsWeb controls
Web controls
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
validation & regular expression chacteristics
validation & regular expression chacteristicsvalidation & regular expression chacteristics
validation & regular expression chacteristics
 
Ajax control tool kit
Ajax control tool kitAjax control tool kit
Ajax control tool kit
 
Ch3 server controls
Ch3 server controlsCh3 server controls
Ch3 server controls
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
 

More from let's go to study

Rs instructor ppt_chapter11_final
Rs instructor ppt_chapter11_finalRs instructor ppt_chapter11_final
Rs instructor ppt_chapter11_final
let's go to study
 
Before beginning
Before beginningBefore beginning
Before beginning
let's go to study
 
Chapter 8 (security)
Chapter 8 (security)Chapter 8 (security)
Chapter 8 (security)
let's go to study
 
Chapter 7 (ado.net)
Chapter 7 (ado.net)Chapter 7 (ado.net)
Chapter 7 (ado.net)
let's go to study
 
Chapter 6 (data binding)
Chapter 6 (data binding)Chapter 6 (data binding)
Chapter 6 (data binding)
let's go to study
 
Chapter 5 (master page)
Chapter 5 (master page)Chapter 5 (master page)
Chapter 5 (master page)
let's go to study
 
Chapter 4 (navigater)
Chapter 4 (navigater)Chapter 4 (navigater)
Chapter 4 (navigater)
let's go to study
 
Chapter 2 (web servercontrol)
Chapter 2 (web servercontrol)Chapter 2 (web servercontrol)
Chapter 2 (web servercontrol)
let's go to study
 
Chapter 1 (asp.net over view)
Chapter 1 (asp.net over view)Chapter 1 (asp.net over view)
Chapter 1 (asp.net over view)
let's go to study
 
Before beginning
Before beginningBefore beginning
Before beginning
let's go to study
 
Sadchap04
Sadchap04Sadchap04
Sadchap03
Sadchap03Sadchap03
Sadchap02
Sadchap02Sadchap02
Sadchap01
Sadchap01Sadchap01
009 sql server management studio
009 sql server management studio009 sql server management studio
009 sql server management studiolet's go to study
 
Chapter 2-html-tage
Chapter 2-html-tageChapter 2-html-tage
Chapter 2-html-tage
let's go to study
 
Chapter 0 before you start
Chapter 0   before you startChapter 0   before you start
Chapter 0 before you start
let's go to study
 

More from let's go to study (20)

Rs instructor ppt_chapter11_final
Rs instructor ppt_chapter11_finalRs instructor ppt_chapter11_final
Rs instructor ppt_chapter11_final
 
Ch10
Ch10Ch10
Ch10
 
Before beginning
Before beginningBefore beginning
Before beginning
 
Chapter 8 (security)
Chapter 8 (security)Chapter 8 (security)
Chapter 8 (security)
 
Chapter 7 (ado.net)
Chapter 7 (ado.net)Chapter 7 (ado.net)
Chapter 7 (ado.net)
 
Chapter 6 (data binding)
Chapter 6 (data binding)Chapter 6 (data binding)
Chapter 6 (data binding)
 
Chapter 5 (master page)
Chapter 5 (master page)Chapter 5 (master page)
Chapter 5 (master page)
 
Chapter 4 (navigater)
Chapter 4 (navigater)Chapter 4 (navigater)
Chapter 4 (navigater)
 
Chapter 2 (web servercontrol)
Chapter 2 (web servercontrol)Chapter 2 (web servercontrol)
Chapter 2 (web servercontrol)
 
Chapter 1 (asp.net over view)
Chapter 1 (asp.net over view)Chapter 1 (asp.net over view)
Chapter 1 (asp.net over view)
 
Before beginning
Before beginningBefore beginning
Before beginning
 
Sadchap04
Sadchap04Sadchap04
Sadchap04
 
Sadchap03
Sadchap03Sadchap03
Sadchap03
 
Sadchap02
Sadchap02Sadchap02
Sadchap02
 
Sadchap01
Sadchap01Sadchap01
Sadchap01
 
database design process
database design processdatabase design process
database design process
 
009 sql server management studio
009 sql server management studio009 sql server management studio
009 sql server management studio
 
007 sql server-installation
007 sql server-installation007 sql server-installation
007 sql server-installation
 
Chapter 2-html-tage
Chapter 2-html-tageChapter 2-html-tage
Chapter 2-html-tage
 
Chapter 0 before you start
Chapter 0   before you startChapter 0   before you start
Chapter 0 before you start
 

Recently uploaded

Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 

Recently uploaded (20)

Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 

Chapter 3 (validation control)

  • 2. Introduction  Used to validate User-Input in an input control.  The page validation is performed when a Button, ImageButton, or Link control is clicked.  Setting CauseValidation to False is to cancel Validation. ValidationControlហ ោសូហនឿន 2
  • 3. Types of Validation Controls  There are 6 types of Validation Controls  RequiredFiledValidator Control  RangeValidator Control  RegularExpressionValidator Control  CompareValidator Control  CustomValidator Control  ValidationSummary Control ValidationControlហ ោសូហនឿន 3
  • 4. RequiredFieldValidator  To make sure that has entered the required data in the input control(TextBox). <asp:RequiredFieldValidator runat=server ID=… ControlToValidate=… ErrorMessage=“…."> </asp:RequiredFieldValidator> ValidationControlហ ោសូហនឿន 4
  • 5. RequiredFieldValidator  See the example: <body> <form id="form1" runat="server"> <asp:TextBox ID=fName runat=server> </asp:TextBox> <asp:RequiredFieldValidator runat=server ID=fNameVal ControlToValidate=fName ErrorMessage="Please Enter the First Name"></asp:RequiredFieldValidator> <asp:Button ID=Submit runat=server Text=Submit /> </form> </body> ValidationControlហ ោសូហនឿន 5
  • 6. RangeValidator  To check that the values input is what in the specified range of values.  There are some important properties:  ControlToValidate  MinimumValue  MaximumValue  Type <asp:RangeValidator runat=server ID=… ControlToValidate=… Type=… MinimumValue=… MaximumValue=… ErrorMessage=“…"> </asp:RangeValidator> ValidationControlហ ោសូហនឿន 6
  • 7. RangeValidator  See the Example: <body> <form id="form1" runat="server"> <asp:TextBox ID=fName runat=server> </asp:TextBox> <asp:RangeValidator runat=server ControlToValidate=fName MinimumValue="A" MaximumValue="Z" Type=String ID=fNameVal ErrorMessage="Capital Only" CultureInvariantValues="True"></asp:RangeValidator> <br /> <asp:Button ID=Submit runat=server Text=Submit /> </form> </body> ValidationControlហ ោសូហនឿន 7
  • 8. RegularExpspressionValidator  To make sure the data input into the input box match the specified the format.  It is made up of text with an embedded code started with a backslash ().  The property ValidateExpression is used the format the data input. ValidationControlហ ោសូហនឿន 8
  • 9. RegularExpspressionValidator  To set the word boundary use  b ….. b  [Range of Input] Example you can set the format for letter input a-z and A-Z as below: b[A-Za-z]+b <asp:TextBox ID=fName runat=server ></asp:TextBox> <asp:RegularExpressionValidator runat=server ID=fNameVal ControlToValidate=fName ValidationExpression="b[A-Z]+b" ErrorMessage="Enter the Letter [a-z, A-Z] only"></asp:RegularExpressionValidator> ValidationControlហ ោសូហនឿន 9
  • 10. RegularExpspressionValidator  There are some more important forms of the expression format. w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)* [0-9]{3}-[0-9]{6} [0-9]{3}-[0-9]{6,7} ValidationControlហ ោសូហនឿន 10
  • 11. CompareValidator  It is used to compare the value entered by a user into an input box to another.  Some properties used with the CompareValidator are:  ControlToCompare  Operator  ValueToCompare  ControlToValidate  Type  ErrorMessage ValidationControlហ ោសូហនឿន 11
  • 12. CompareValidator  The Operator property has the following value:  Equal  NotEqual  GreaterThan  GreaterThanEqual  LessThan  LessThanEqual  DataTypeCheck ValidationControlហ ោសូហនឿន 12
  • 13. CompareValidator  See the example: <body> <form id="form1" runat="server"> User Name: <asp:TextBox ID=txtuser runat=server > </asp:TextBox> <asp:CompareValidator runat=server ControlToValidate=txtuser ValueToCompare="sonoeun" ErrorMessage="Invalid User Name"> </asp:CompareValidator> <br /> <asp:Button runat=server ID=bntSubmit Text=Submit /> </form> </body> ValidationControlហ ោសូហនឿន 13
  • 14. CustomValidator  To check that the data input matches the a given condition or not.  It is a powerful way to use the Validator controls since you can write your own customization code.  It uses the main properties and methods as below:  ClientValidationFunction: To set the name of the custom client-side script function used for Validation.  ValidateEmptyText: To set a boolean value to make sure if the empty text should be validated or not.  ServerValidate : The method occurring when the validation takes place on the server. ValidationControlហ ោសូហនឿន 14
  • 15. CustomValidator  See the Example <body> <form id="form1" runat="server"> <script language=vbscript runat=server type="text/vbscript" > Sub serverVal(ByVal source, ByVal objServer) If (objServer.value = "ServerValidation") Then objServer.IsValid = True lbl.Text = "Subscription Successful" Else objServer.IsValid = False lbl.Text = "Subscription Not Successful" End If End Sub </script> ValidationControlហ ោសូហនឿន 15
  • 16. CustomValidator  See the Example (cont.) <asp:TextBox ID=ServerObj runat=server ></asp:TextBox> <asp:CustomValidator ID=ServerObjVal runat=server OnServerValidate="serverVal" ControlToValidate=ServerObj ErrorMessage="Subscription NOT Accepted"> </asp:CustomValidator> <br /> <asp:Button runat=server ID=submitServer Text=Submit /> <br /> <asp:label ID=lbl runat=server ></asp:label> </form> </body> ValidationControlហ ោសូហនឿន 16
  • 17. ValidationSummary  It collects all validation control error messages for centralized display.  It can be displayed as a list, a bullet list, a single paragraph depending on the DisplayMode  Specifying the summary display by setting ShowSummary and ShowMessageBox properties. ValidationControlហ ោសូហនឿន 17
  • 18. ValidationSummary  Some properties you should know when you use validationSummary are:  DisplayedMode  EnableClientScript  ForeColor  HeaderText  ShowMessageBox  ShowSummary ValidationControlហ ោសូហនឿន 18
  • 19. ValidationSummary  See The Example: <body> <form id="form1" runat="server"> First Name: <asp:TextBox ID=fName runat=server ></asp:TextBox> <asp:RequiredFieldValidator runat=server ID=RefNameVal ControlToValidate=fName ErrorMessage="First Name Needed"></asp:RequiredFieldValidator> <asp:RegularExpressionValidator runat=server ID=EprfNameVal ControlToValidate=fName ValidationExpression="b[A-z]+b" ErrorMessage="No Number Permited"> </asp:RegularExpressionValidator> <br /> Last Name: <asp:TextBox ID=lName runat=server></asp:TextBox> ValidationControlហ ោសូហនឿន 19
  • 20. ValidationSummary  See The Example: <asp:RequiredFieldValidator runat=server ID=RelNameVal ControlToValidate=lName ErrorMessage="Last Name Needed"></asp:RequiredFieldValidator> <asp:RegularExpressionValidator runat=server ID=ExplNameVal ValidationExpression="b[A-Z]+b" ControlToValidate=lName ErrorMessage="Capital Letter Only"> </asp:RegularExpressionValidator> <br/> <asp:Button runat=server ID=btnSubmit Text=Submit /> <br /> <asp:ValidationSummary ID=valSummary ShowMessageBox=true runat=server /> </form> </body> ValidationControlហ ោសូហនឿន 20
  • 21. ValidationGroup  It a property of Validator controls.  Setting ValidationGroup, it validates only the validation controls within the specified group when the control is post back to the server.  It is used to assign a validation control to a validation group. ValidationControlហ ោសូហនឿន 21
  • 22. ValidationGroup  Example ValidationControlហ ោសូហនឿន 22 <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" Runat="server" ValidationGroup="First"> </asp:TextBox> <asp:TextBox ID="TextBox2" Runat="server" ValidationGroup="First"> </asp:TextBox><br /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server" ValidationGroup="First" ErrorMessage="TextBox1 should not be blank" ControlToValidate="TextBox1"> </asp:RequiredFieldValidator> <asp:Button ID="Submit1" Runat="server" ValidationGroup="First" Text="Submit 1" /> <br /> <br />
  • 23. ValidationGroup ValidationControlហ ោសូហនឿន 23 <asp:TextBox ID="TextBox3" Runat="server" ValidationGroup="Second"> </asp:TextBox> <asp:TextBox ID="TextBox4" Runat="server" ValidationGroup="Second"> </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server" ErrorMessage=" TextBox3 should not be blank" ControlToValidate="TextBox3" ValidationGroup="Second"> </asp:RequiredFieldValidator> <asp:Button ID="Submit2" Runat="server" ValidationGroup="Second" Text="Submit 2" /> </div> </form> </body>