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

What's hot (20)

Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
Web Services ppt
Web Services pptWeb Services ppt
Web Services ppt
 
Xml presentation
Xml presentationXml presentation
Xml presentation
 
Webservices
WebservicesWebservices
Webservices
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 
Restful web services ppt
Restful web services pptRestful web services ppt
Restful web services ppt
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 
AngularJS
AngularJSAngularJS
AngularJS
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
Tutorial 2 - Basic Communication on the Internet: Email
Tutorial 2 - Basic Communication on the Internet: EmailTutorial 2 - Basic Communication on the Internet: Email
Tutorial 2 - Basic Communication on the Internet: Email
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Introduction to API
Introduction to APIIntroduction to API
Introduction to API
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Authentication & Authorization in ASPdotNet MVC
Authentication & Authorization in ASPdotNet MVCAuthentication & Authorization in ASPdotNet MVC
Authentication & Authorization in ASPdotNet MVC
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and REST
 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
 
Html5 for mobiles
Html5 for mobilesHtml5 for mobiles
Html5 for mobiles
 
Interfaces .net
Interfaces .netInterfaces .net
Interfaces .net
 
Method overloading
Method overloadingMethod overloading
Method overloading
 

Similar to Validation Controls in .NET

ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10Sisir Ghosh
 
Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.netDeep Patel
 
Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controlsGuddu gupta
 
Validation in asp.net
Validation in asp.netValidation in asp.net
Validation in asp.netSireesh K
 
validation
validationvalidation
validationteach4uin
 
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 o3iCoRRexGaMing
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in aspShishir Jain
 
Spring REST Request Validation
Spring REST Request ValidationSpring REST Request Validation
Spring REST Request ValidationMohammad Sabir Khan
 
Chapter 3 (validation control)
Chapter 3 (validation control)Chapter 3 (validation control)
Chapter 3 (validation control)let's go to study
 
Asp.net validation
Asp.net validationAsp.net validation
Asp.net validationPaneliya Prince
 
validation
validationvalidation
validationteach4uin
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCBarry Gervin
 
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.pptxYamunaS38
 
MVC 3-RAZOR Validation
MVC 3-RAZOR ValidationMVC 3-RAZOR Validation
MVC 3-RAZOR ValidationKrunal Trivedi
 
Test Automation Frameworks Final
Test Automation Frameworks   FinalTest Automation Frameworks   Final
Test Automation Frameworks FinalMargaret_Dickman
 
Wielding Workflow
Wielding WorkflowWielding Workflow
Wielding Workflowdreamforce2006
 
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptxChapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptxilhamilyas5
 
Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Ilio Catallo
 

Similar to Validation Controls in .NET (20)

ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
 
Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.net
 
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
 

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

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A BeĂąa
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 

Recently uploaded (20)

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 

Validation Controls in .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