SlideShare a Scribd company logo
1 of 18
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
VALIDATION CONTROLS IN .NET
ARJUN S R
Arjun.sr007@gmail.com
www.facebook.com/arjun.a
ryavartham
twitter.com/arjun.sr007
in.linkedin.com/in/arjun.sr0
07
9745649882
• A validation control (or validator) determines whether the
data in another web control is in the proper format, before the
data is processed.
• When the XHTML for our page is created, the validator is
converted into JavaScript that performs the validation
• JavaScript is a scripting language that enhances the
functionality and appearance of web pages and is typically
executed on the client.
• Because some clients disable or do not support scripting,
ASP.NET validation controls can function on the client,
on the server or both.
WHAT VALIDATION CONTROLS
DO?
• Rich, declarative validation
• Validation declared separately from input control
• Extensible validation framework
• Supports validation on client and server
• Server-side validation is always done
– Prevents users from spoofing Web Forms
• Validate User inputs
75% of code for handling exceptions
Simplify task
SIX VALIDATION CONTROLS
1. RequiredFieldValidator
 Ensures that a value is entered
• <asp: RequiredFieldValidator
2. CompareValidator
– Compares input to: data type, constant, another control,
database value, etc
– <asp: CompareValidator>
3. RangeValidator
– Entry within a specified data range
– <asp: RangeValidator>
4. ValidationSummary
– Summarizes all errors on page
– <asp: ValidationSummary>
4. RegularExpressionValidator
– Check format against a specific pattern
– E-mail address, phone number, zip code, etc
– <asp: RegularExpressionValidator>
5. CustomValidator
– Write own code
– Server- or client-side
– <asp: CustomValidator>
• Validation controls are derived from
System.Web.UI.WebControls.BaseValidator, which is derived
from the Label control
• Validation controls contain text which is displayed only if validation fails
• Text property is displayed at control location
• ErrorMessage is displayed in summary
• Page.IsValid indicates if all validation controls on the page succeed
void Submit_click(object s, EventArgs e) {
if (Page.IsValid) {
Message. Text = "Page is valid!";
}
}
RequiredFieldValidator
<asp: RequiredFieldValidator id=”reqFirstName”
ControlToValidate=”txtFirstName” Text=”(Required)”
SetFocusOnError=”true” Runat=”server” />
CompareValidator
<asp: CompareValidator id=”cmpBirthDate” Text=”(Invalid Date)”
ControlToValidate=”txtBirthDate” Type=”Date”
Operator=”DataTypeCheck” Runat=”server” />
RangeValidator
<asp: RangeValidator id=”reqAge” ControlToValidate=”txtAge”
Text=”(Invalid Age)” MinimumValue=”5” MaximumValue=”100”
Type=”Integer” Runat=”server” />
ValidationSummary
<asp: ValidationSummary id=”ValidationSummary1” ShowMessageBox=”true”
ShowSummary=”false” Runat=”server” />
RegularExpressionValidator
• <asp: RegularExpressionValidator id=”regEmail”
ControlToValidate=”txtEmail” Text=”(Invalid email)”
ValidationExpression=”w+([-+.’]w+)*@w+([-.]w+)*.w+([-.]w+)*”
Runat=”server” />
CustomValidator
• <asp: CustomValidator id=”valComments”
ControlToValidate=”txtComments”
Text=”(Comments must be less than 10 characters)”
OnServerValidate=”valComments_ServerValidate”
Runat=”server” />
BENEFITS AND LIMITATIONS
Benefits
– Convenience
• Cut & paste
– Bomb-proof
• Server-side validation
Limitations
– Must remember to check on server
• Page.IsValid statement
– Different interpretations of regular expressions
• JavaScript vs. server
• minor issue
SUMMARY
• Easy to use
• Flexible
– Validate any type of input
• Combines client- and server-side validation in one
control
• Bomb-proof server-side validation
this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com

More Related Content

What's hot

Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 

What's hot (20)

Javascript 101
Javascript 101Javascript 101
Javascript 101
 
CSS
CSSCSS
CSS
 
Intro to html 5
Intro to html 5Intro to html 5
Intro to html 5
 
New Form Element in HTML5
New Form Element in HTML5New Form Element in HTML5
New Form Element in HTML5
 
Introduction to React Native - Nader Dabit
Introduction to React Native - Nader DabitIntroduction to React Native - Nader Dabit
Introduction to React Native - Nader Dabit
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
ASP.NET 07 - Site Navigation
ASP.NET 07 - Site NavigationASP.NET 07 - Site Navigation
ASP.NET 07 - Site Navigation
 
Introduction to React Native Workshop
Introduction to React Native WorkshopIntroduction to React Native Workshop
Introduction to React Native Workshop
 
Html forms
Html formsHtml forms
Html forms
 
Html 5 New Features
Html 5 New FeaturesHtml 5 New Features
Html 5 New Features
 
Javascript
JavascriptJavascript
Javascript
 
LINQ in C#
LINQ in C#LINQ in C#
LINQ in C#
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Html forms
Html formsHtml forms
Html forms
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
Java Swing
Java SwingJava Swing
Java Swing
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Php forms
Php formsPhp forms
Php forms
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
 

Similar to Validation controls ASP .NET

ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
Sisir Ghosh
 
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
 
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptxChapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
ilhamilyas5
 

Similar to Validation controls ASP .NET (20)

ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
 
Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
 
Validation in asp.net
Validation in asp.netValidation in asp.net
Validation in asp.net
 
2310 b 07
2310 b 072310 b 07
2310 b 07
 
validation
validationvalidation
validation
 
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 controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
 
Spring REST Request Validation
Spring REST Request ValidationSpring REST Request Validation
Spring REST Request Validation
 
Chapter 3 (validation control)
Chapter 3 (validation control)Chapter 3 (validation control)
Chapter 3 (validation control)
 
Asp.net validation
Asp.net validationAsp.net validation
Asp.net validation
 
validation
validationvalidation
validation
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
 
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
 
MVC 3-RAZOR Validation
MVC 3-RAZOR ValidationMVC 3-RAZOR Validation
MVC 3-RAZOR Validation
 
Test Automation Frameworks Final
Test Automation Frameworks   FinalTest Automation Frameworks   Final
Test Automation Frameworks Final
 
Wielding Workflow
Wielding WorkflowWielding Workflow
Wielding Workflow
 
Web controls
Web controlsWeb controls
Web controls
 
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptxChapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
 
Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 

More from baabtra.com - No. 1 supplier of quality freshers

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 

Validation controls ASP .NET

  • 1.
  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3. VALIDATION CONTROLS IN .NET ARJUN S R Arjun.sr007@gmail.com www.facebook.com/arjun.a ryavartham twitter.com/arjun.sr007 in.linkedin.com/in/arjun.sr0 07 9745649882
  • 4. • A validation control (or validator) determines whether the data in another web control is in the proper format, before the data is processed. • When the XHTML for our page is created, the validator is converted into JavaScript that performs the validation • JavaScript is a scripting language that enhances the functionality and appearance of web pages and is typically executed on the client. • Because some clients disable or do not support scripting, ASP.NET validation controls can function on the client, on the server or both.
  • 5. WHAT VALIDATION CONTROLS DO? • Rich, declarative validation • Validation declared separately from input control • Extensible validation framework • Supports validation on client and server • Server-side validation is always done – Prevents users from spoofing Web Forms • Validate User inputs 75% of code for handling exceptions Simplify task
  • 7. 1. RequiredFieldValidator  Ensures that a value is entered • <asp: RequiredFieldValidator 2. CompareValidator – Compares input to: data type, constant, another control, database value, etc – <asp: CompareValidator> 3. RangeValidator – Entry within a specified data range – <asp: RangeValidator> 4. ValidationSummary – Summarizes all errors on page – <asp: ValidationSummary>
  • 8. 4. RegularExpressionValidator – Check format against a specific pattern – E-mail address, phone number, zip code, etc – <asp: RegularExpressionValidator> 5. CustomValidator – Write own code – Server- or client-side – <asp: CustomValidator>
  • 9. • Validation controls are derived from System.Web.UI.WebControls.BaseValidator, which is derived from the Label control • Validation controls contain text which is displayed only if validation fails • Text property is displayed at control location • ErrorMessage is displayed in summary • Page.IsValid indicates if all validation controls on the page succeed void Submit_click(object s, EventArgs e) { if (Page.IsValid) { Message. Text = "Page is valid!"; } }
  • 10. RequiredFieldValidator <asp: RequiredFieldValidator id=”reqFirstName” ControlToValidate=”txtFirstName” Text=”(Required)” SetFocusOnError=”true” Runat=”server” />
  • 11. CompareValidator <asp: CompareValidator id=”cmpBirthDate” Text=”(Invalid Date)” ControlToValidate=”txtBirthDate” Type=”Date” Operator=”DataTypeCheck” Runat=”server” />
  • 12. RangeValidator <asp: RangeValidator id=”reqAge” ControlToValidate=”txtAge” Text=”(Invalid Age)” MinimumValue=”5” MaximumValue=”100” Type=”Integer” Runat=”server” />
  • 13. ValidationSummary <asp: ValidationSummary id=”ValidationSummary1” ShowMessageBox=”true” ShowSummary=”false” Runat=”server” />
  • 14. RegularExpressionValidator • <asp: RegularExpressionValidator id=”regEmail” ControlToValidate=”txtEmail” Text=”(Invalid email)” ValidationExpression=”w+([-+.’]w+)*@w+([-.]w+)*.w+([-.]w+)*” Runat=”server” />
  • 15. CustomValidator • <asp: CustomValidator id=”valComments” ControlToValidate=”txtComments” Text=”(Comments must be less than 10 characters)” OnServerValidate=”valComments_ServerValidate” Runat=”server” />
  • 16. BENEFITS AND LIMITATIONS Benefits – Convenience • Cut & paste – Bomb-proof • Server-side validation Limitations – Must remember to check on server • Page.IsValid statement – Different interpretations of regular expressions • JavaScript vs. server • minor issue
  • 17. SUMMARY • Easy to use • Flexible – Validate any type of input • Combines client- and server-side validation in one control • Bomb-proof server-side validation
  • 18. this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com