SlideShare a Scribd company logo
Validation controls ASP .NET
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 (20)

PPT
ADO .Net
DrSonali Vyas
 
PPT
Web controls
Sarthak Varshney
 
PPTX
Selenium WebDriver
Yuriy Bezgachnyuk
 
PPTX
Html
EPAM Systems
 
PPTX
Objects and classes in Visual Basic
Sangeetha Sg
 
PDF
UDA-Componentes RUP. Fecha
Ander Martinez
 
PPT
C# Basics
Sunil OS
 
PDF
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
PPTX
Io streams
Elizabeth alexander
 
PDF
Android Programming Basics
Eueung Mulyana
 
PPT
Asp.net server controls
Raed Aldahdooh
 
PPTX
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Nuzhat Memon
 
PPTX
Break,Pass and Continue.pptx
UjjwalGupta604782
 
PPTX
Python idle introduction(3)
Fahad Ashrafi
 
PPT
7.data types in c#
Zeeshan Ahmad
 
PDF
Introduction to Gnu/Linux
Ranjith Siji
 
PPTX
Exception handling
Ardhendu Nandi
 
PDF
JavaScript - Chapter 3 - Introduction
WebStackAcademy
 
PPTX
Form Validation in JavaScript
Ravi Bhadauria
 
PPTX
Chapter 1
gebrsh
 
ADO .Net
DrSonali Vyas
 
Web controls
Sarthak Varshney
 
Selenium WebDriver
Yuriy Bezgachnyuk
 
Objects and classes in Visual Basic
Sangeetha Sg
 
UDA-Componentes RUP. Fecha
Ander Martinez
 
C# Basics
Sunil OS
 
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
Android Programming Basics
Eueung Mulyana
 
Asp.net server controls
Raed Aldahdooh
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Nuzhat Memon
 
Break,Pass and Continue.pptx
UjjwalGupta604782
 
Python idle introduction(3)
Fahad Ashrafi
 
7.data types in c#
Zeeshan Ahmad
 
Introduction to Gnu/Linux
Ranjith Siji
 
Exception handling
Ardhendu Nandi
 
JavaScript - Chapter 3 - Introduction
WebStackAcademy
 
Form Validation in JavaScript
Ravi Bhadauria
 
Chapter 1
gebrsh
 

Similar to Validation controls ASP .NET (20)

PPT
ASP.NET Session 10
Sisir Ghosh
 
PPTX
Asp.NET Validation controls
Guddu gupta
 
PPTX
Validation in asp.net
Sireesh K
 
PPT
2310 b 07
Krazy Koder
 
PPT
validation
teach4uin
 
PDF
validation-controls.pdf ioue8n uoh souu o3i
CoRRexGaMing
 
PPTX
Validation controls in asp
Shishir Jain
 
PPTX
Spring REST Request Validation
Mohammad Sabir Khan
 
PDF
Chapter 3 (validation control)
let's go to study
 
PPTX
Asp.net validation
Paneliya Prince
 
PPT
validation
teach4uin
 
PPT
CTTDNUG ASP.NET MVC
Barry Gervin
 
PPTX
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
YamunaS38
 
PPTX
MVC 3-RAZOR Validation
Krunal Trivedi
 
PPT
Test Automation Frameworks Final
Margaret_Dickman
 
PPT
Wielding Workflow
dreamforce2006
 
PPTX
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
ilhamilyas5
 
PDF
Validation in Jakarta Struts 1.3
Ilio Catallo
 
PPTX
Chapter 9
application developer
 
PPTX
Secure Development on the Salesforce Platform - Part 2
Salesforce Developers
 
ASP.NET Session 10
Sisir Ghosh
 
Asp.NET Validation controls
Guddu gupta
 
Validation in asp.net
Sireesh K
 
2310 b 07
Krazy Koder
 
validation
teach4uin
 
validation-controls.pdf ioue8n uoh souu o3i
CoRRexGaMing
 
Validation controls in asp
Shishir Jain
 
Spring REST Request Validation
Mohammad Sabir Khan
 
Chapter 3 (validation control)
let's go to study
 
Asp.net validation
Paneliya Prince
 
validation
teach4uin
 
CTTDNUG ASP.NET MVC
Barry Gervin
 
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
YamunaS38
 
MVC 3-RAZOR Validation
Krunal Trivedi
 
Test Automation Frameworks Final
Margaret_Dickman
 
Wielding Workflow
dreamforce2006
 
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
ilhamilyas5
 
Validation in Jakarta Struts 1.3
Ilio Catallo
 
Secure Development on the Salesforce Platform - Part 2
Salesforce Developers
 
Ad

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

PPTX
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
PDF
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Ad

Recently uploaded (20)

PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 

Validation controls ASP .NET

  • 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 [email protected] 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