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
Ad

Recommended

Html
Html
Mallikarjuna G D
 
Soap web service
Soap web service
NITT, KAMK
 
Angular 2
Angular 2
Nigam Goyal
 
Asp.net architecture
Asp.net architecture
Iblesoft
 
Selenide
Selenide
DataArt
 
Js ppt
Js ppt
Rakhi Thota
 
What is SSL/TLS, 1-way and 2-way SSL?
What is SSL/TLS, 1-way and 2-way SSL?
pqrs1234
 
javascript objects
javascript objects
Vijay Kalyan
 
Web forms in ASP.net
Web forms in ASP.net
Madhuri Kavade
 
Selenium- A Software Testing Tool
Selenium- A Software Testing Tool
Zeba Tahseen
 
ECMA Script
ECMA Script
NodeXperts
 
Validation Controls in asp.net
Validation Controls in asp.net
Deep Patel
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
Zoe Gilbert
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
Web api
Web api
Sudhakar Sharma
 
HTML5 Form Validation
HTML5 Form Validation
Ian Oxley
 
JavaScript Promises
JavaScript Promises
L&T Technology Services Limited
 
Postman
Postman
Igor Shubovych
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle Methods
ANKUSH CHAVAN
 
Asp.net mvc basic introduction
Asp.net mvc basic introduction
Bhagath Gopinath
 
Javascript arrays
Javascript arrays
Hassan Dar
 
Introduction to Apex for Developers
Introduction to Apex for Developers
Salesforce Developers
 
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Pankaj Dubey
 
Introduction to Sightly
Introduction to Sightly
Ankit Gubrani
 
AngularJS
AngularJS
Srivatsan Krishnamachari
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
CSS
CSS
Akila Iroshan
 
ASP.NET Web form
ASP.NET Web form
Md. Mahedee Hasan
 
validation-controls.pdf ioue8n uoh souu o3i
validation-controls.pdf ioue8n uoh souu o3i
CoRRexGaMing
 
Validation in asp.net
Validation in asp.net
Sireesh K
 

More Related Content

What's hot (20)

Web forms in ASP.net
Web forms in ASP.net
Madhuri Kavade
 
Selenium- A Software Testing Tool
Selenium- A Software Testing Tool
Zeba Tahseen
 
ECMA Script
ECMA Script
NodeXperts
 
Validation Controls in asp.net
Validation Controls in asp.net
Deep Patel
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
Zoe Gilbert
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
Web api
Web api
Sudhakar Sharma
 
HTML5 Form Validation
HTML5 Form Validation
Ian Oxley
 
JavaScript Promises
JavaScript Promises
L&T Technology Services Limited
 
Postman
Postman
Igor Shubovych
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle Methods
ANKUSH CHAVAN
 
Asp.net mvc basic introduction
Asp.net mvc basic introduction
Bhagath Gopinath
 
Javascript arrays
Javascript arrays
Hassan Dar
 
Introduction to Apex for Developers
Introduction to Apex for Developers
Salesforce Developers
 
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Pankaj Dubey
 
Introduction to Sightly
Introduction to Sightly
Ankit Gubrani
 
AngularJS
AngularJS
Srivatsan Krishnamachari
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
CSS
CSS
Akila Iroshan
 
ASP.NET Web form
ASP.NET Web form
Md. Mahedee Hasan
 
Selenium- A Software Testing Tool
Selenium- A Software Testing Tool
Zeba Tahseen
 
Validation Controls in asp.net
Validation Controls in asp.net
Deep Patel
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
Zoe Gilbert
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
HTML5 Form Validation
HTML5 Form Validation
Ian Oxley
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle Methods
ANKUSH CHAVAN
 
Asp.net mvc basic introduction
Asp.net mvc basic introduction
Bhagath Gopinath
 
Javascript arrays
Javascript arrays
Hassan Dar
 
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Pankaj Dubey
 
Introduction to Sightly
Introduction to Sightly
Ankit Gubrani
 

Similar to Validation controls ASP .NET (20)

validation-controls.pdf ioue8n uoh souu o3i
validation-controls.pdf ioue8n uoh souu o3i
CoRRexGaMing
 
Validation in asp.net
Validation in asp.net
Sireesh K
 
Asp.net validation
Asp.net validation
Paneliya Prince
 
Asp.NET Validation controls
Asp.NET Validation controls
Guddu gupta
 
validation
validation
teach4uin
 
Validation controls in asp
Validation controls in asp
KS Technologies Vadodara
 
Validation controls in asp
Validation controls in asp
Shishir Jain
 
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
YamunaS38
 
validation
validation
teach4uin
 
Chapter 9
Chapter 9
application developer
 
Validation controls ppt
Validation controls ppt
Iblesoft
 
validation of aap.net
validation of aap.net
Pratiksha Srivastava
 
ASP.NET Session 10
ASP.NET Session 10
Sisir Ghosh
 
ASP.NET Validation Control
ASP.NET Validation Control
ZAIYAUL HAQUE
 
Introduction to validation
Introduction to validation
rlavadiya
 
asp.net controls
asp.net controls
baabtra.com - No. 1 supplier of quality freshers
 
Defending against Injections
Defending against Injections
Blueinfy Solutions
 
2310 b 07
2310 b 07
Krazy Koder
 
LAYERS asp.net ppt
LAYERS asp.net ppt
IMEI
 
Controls in asp.net
Controls in asp.net
baabtra.com - No. 1 supplier of quality freshers
 
Ad

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

Agile methodology and scrum development
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Best coding practices
Best coding practices
baabtra.com - No. 1 supplier of quality freshers
 
Core java - baabtra
Core java - baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Acquiring new skills what you should know
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Php sessions & cookies
Php sessions & cookies
baabtra.com - No. 1 supplier of quality freshers
 
Php database connectivity
Php database connectivity
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 3 stored procedures
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
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
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Microsoft holo lens
Microsoft holo lens
baabtra.com - No. 1 supplier of quality freshers
 
Blue brain
Blue brain
baabtra.com - No. 1 supplier of quality freshers
 
5g
5g
baabtra.com - No. 1 supplier of quality freshers
 
Aptitude skills baabtra
Aptitude skills baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Gd baabtra
Gd baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Ad

Recently uploaded (20)

Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Gladiolous Cultivation practices by AKL.pdf
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Q1_TLE 8_Week 1- Day 1 tools and equipment
Q1_TLE 8_Week 1- Day 1 tools and equipment
clairenotado3
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Rajdeep Bavaliya
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Gladiolous Cultivation practices by AKL.pdf
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Q1_TLE 8_Week 1- Day 1 tools and equipment
Q1_TLE 8_Week 1- Day 1 tools and equipment
clairenotado3
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Rajdeep Bavaliya
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 

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