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

AdRotator and AdRepeater Control in Asp.Net for Msc CS
AdRotator and AdRepeater Control in Asp.Net for Msc CSAdRotator and AdRepeater Control in Asp.Net for Msc CS
AdRotator and AdRepeater Control in Asp.Net for Msc CS
Thanveen
 

What's hot (20)

Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
 
Exception handling
Exception handlingException handling
Exception handling
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
7.data types in c#
7.data types in c#7.data types in c#
7.data types in c#
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Array vs array list
Array vs array listArray vs array list
Array vs array list
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
CSS.ppt
CSS.pptCSS.ppt
CSS.ppt
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
CSS media types
CSS media typesCSS media types
CSS media types
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
AdRotator and AdRepeater Control in Asp.Net for Msc CS
AdRotator and AdRepeater Control in Asp.Net for Msc CSAdRotator and AdRepeater Control in Asp.Net for Msc CS
AdRotator and AdRepeater Control in Asp.Net for Msc CS
 
Html phrase tags
Html phrase tagsHtml phrase tags
Html phrase tags
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQL
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 

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

Recently uploaded (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).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
 
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...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
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)
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
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.
 
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
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
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.
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

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