SlideShare a Scribd company logo
1 of 17
Uint – II
(.Net Framework)
ASP.NET Controls
Web Server controls
 TextBox: A control used to capture user input.
 Button: A control used to initiate an action on the server.
 DropDownList: A control used to provide a list of options for the user to
choose from.
 GridView: A control used to display and manipulate data in a tabular
format.
 Calendar: A control used to display a calendar for selecting dates.
HTML Server Control
 Textbox: A control used to capture user input.
 Button: A control used to initiate an action on the server.
 Dropdown list: A control used to provide a list of options for the user to
choose from.
 Checkbox: A control used to capture boolean input.
 Radio button: A control used to provide a list of mutually exclusive options
for the user to choose from.
 Image: A control used to display images on the web page.
Web User Controls
 Header/Footer controls: These controls are used to create consistent
headers and footers across different pages.
 Navigation controls: These controls are used to create consistent
navigation menus across different pages.
 Search controls: These controls are used to create consistent search
functionality across different pages.
 Login controls: These controls are used to create consistent login
functionality across different pages.
Goals
Check validity of data from the end user
 Why
 To maintain data integrity
 How
 Check user input on the client side or on the server side
 Examples
 Is the name Textbox empty?
 Does the email Textbox contain a structurally valid email
address?
Client Side Vs Server Side
Client-side validation
 Done in the browser
 Uses JavaScript
 Does not require HTTP
request + response
Server-side validation
 Done on the server
 Uses C#
 Requires HTTP request
+ response
 RequiredFieldValidator
Input field cannot be empty
 CompareValidator
Compare between user inputs using =, >, etc.
 RangeValidator
Minimum < input < maximum
 RegularExpressionValidator
Check the entry matches a pattern defined by the regular expression
 CustomValidator
Make your own validator
 ValidationSummary
Displays all error messages from validators in one spot
ASPNET Validation Controls
 ControlToValidate
The control to be validated
 ErrorMessage
The message used in the ValidationSummary
 Text
The error message used in the validation control
 CssClass
Style appearance of the messages
Common Properties of Validation Controls
 The RequiredFieldValidator control ensures that the required field is not
empty. It is generally tied to a text box to force input into the text box.
The syntax for the control:
<asp:RequiredFieldValidator ID="rfvcandidate"
runat="server" ControlToValidate="ddlcandidate"
ErrorMessage="Please choose a candidate"
InitialValue="Please choose a candidate">
</asp:RequiredFieldValidator>
Required Field Validator
 The CompareValidator control compares a value in one control with a fixed
value, or, a value in another control.
 It has the following specific properties:
The basic syntax for the control:
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator">
</asp:CompareValidator>
Compare Validator
 The RangeValidator control verifies that the input value falls within a
predetermined range.
 It has three specific properties:
The syntax for the control:
<asp:RangeValidator ID="rvclass" runat="server" ControlToValidate="txtclass" ErrorMessage="Enter
your class (6 - 12)" MaximumValue="12" MinimumValue="6" Type="Integer">
</asp:RangeValidator>
Range Validator
 The RegularExpressionValidator allows validating the input text by matching
against a pattern against a regular expression. The regular expression is set
in the ValidationExpression property.
 The following table summarizes the commonly used syntax constructs for
regular expressions:
Regular Expression Validator
<asp:RegularExpressionValidator ID="RegExpVal2" runat="server"
ErrorMessage = "Please Enter Valid Email ID“ ValidationGroup="vgSubmit"
ControlToValidate="txtEmail" CssClass="requiredFieldValidateStyle"
ForeColor="Red" ValidationExpression="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*">
</asp:RegularExpressionValidator>
 The CustomValidator control allows writing application specific custom
validation routines for both the client side and the server side validation.
 The server side validation routine should be written in any .Net language,
like C# or VB.Net.
The basic syntax for the control:
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction=.cvf_func.
ErrorMessage="CustomValidator"></asp:CustomValidator>
Custom Validator
 The ValidationSummary control does not perform any validation but shows a
summary of all errors in the page. The summary displays the values of the
ErrorMessage property of all validation controls that failed validation.
 Using Page.IsValid property we can check for page errors. When there are no
errors IsValid returns true and user can proceed to next page.
if (Page.IsValid)
{ //validation complete proceed }
runat="server"
The syntax for the control:
<asp:ValidationSummary ID="ValidationSummary1"
DisplayMode = "BulletList" ShowSummary = "true"
HeaderText="Errors:" />
Validation Summary
Base Validator Class
Validation Group
Second problem = when I click the Login button, only fields in the Login section
(Username & Password) needs to be validated. Along the same lines when I click the
"Register" button, only fields in the Registration section(Email, Username, Password and
ConfirmPassword) needs to validated. If we don't use validation groups, then by default,
whenever, you click any button, all the validation controls on the page get validated.
So, when you click the login button, and if you want only, the fields in the Login
section(Username and Password) to be validated, then set, the Validationgroup property
of the validation controls and the login button control to the same group name. Use a
different group name for the validation controls and register button, in the registration
section.
First Problem: when I click the Clear
button, Form validation still happens.
When I click the clear button, I just want
to clear the textboxes in the
Registration section. Validations doesn't
make any sense here. So, how do I
prevent validation from happening?
Answer: CausesValidation=“False”
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx

More Related Content

Similar to vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx

Similar to vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx (20)

Asp.net validation
Asp.net validationAsp.net validation
Asp.net validation
 
Chapter 3 (validation control)
Chapter 3 (validation control)Chapter 3 (validation control)
Chapter 3 (validation control)
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
 
Web controls
Web controlsWeb controls
Web controls
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
Visual studio 2008 asp net
Visual studio 2008 asp netVisual studio 2008 asp net
Visual studio 2008 asp net
 
validation
validationvalidation
validation
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server Controls
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
Validation controls ASP .NET
Validation controls ASP .NETValidation controls ASP .NET
Validation controls ASP .NET
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9
 
Ajax control tool kit
Ajax control tool kitAjax control tool kit
Ajax control tool kit
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
validation of aap.net
validation of aap.netvalidation of aap.net
validation of aap.net
 
ASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server ControlsASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server Controls
 
LAYERS asp.net ppt
LAYERS asp.net pptLAYERS asp.net ppt
LAYERS asp.net ppt
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
Asp PPT (.NET )
Asp PPT (.NET )Asp PPT (.NET )
Asp PPT (.NET )
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 

vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx

  • 1. Uint – II (.Net Framework) ASP.NET Controls
  • 2. Web Server controls  TextBox: A control used to capture user input.  Button: A control used to initiate an action on the server.  DropDownList: A control used to provide a list of options for the user to choose from.  GridView: A control used to display and manipulate data in a tabular format.  Calendar: A control used to display a calendar for selecting dates.
  • 3. HTML Server Control  Textbox: A control used to capture user input.  Button: A control used to initiate an action on the server.  Dropdown list: A control used to provide a list of options for the user to choose from.  Checkbox: A control used to capture boolean input.  Radio button: A control used to provide a list of mutually exclusive options for the user to choose from.  Image: A control used to display images on the web page.
  • 4. Web User Controls  Header/Footer controls: These controls are used to create consistent headers and footers across different pages.  Navigation controls: These controls are used to create consistent navigation menus across different pages.  Search controls: These controls are used to create consistent search functionality across different pages.  Login controls: These controls are used to create consistent login functionality across different pages.
  • 5. Goals Check validity of data from the end user  Why  To maintain data integrity  How  Check user input on the client side or on the server side  Examples  Is the name Textbox empty?  Does the email Textbox contain a structurally valid email address?
  • 6. Client Side Vs Server Side Client-side validation  Done in the browser  Uses JavaScript  Does not require HTTP request + response Server-side validation  Done on the server  Uses C#  Requires HTTP request + response
  • 7.  RequiredFieldValidator Input field cannot be empty  CompareValidator Compare between user inputs using =, >, etc.  RangeValidator Minimum < input < maximum  RegularExpressionValidator Check the entry matches a pattern defined by the regular expression  CustomValidator Make your own validator  ValidationSummary Displays all error messages from validators in one spot ASPNET Validation Controls
  • 8.  ControlToValidate The control to be validated  ErrorMessage The message used in the ValidationSummary  Text The error message used in the validation control  CssClass Style appearance of the messages Common Properties of Validation Controls
  • 9.  The RequiredFieldValidator control ensures that the required field is not empty. It is generally tied to a text box to force input into the text box. The syntax for the control: <asp:RequiredFieldValidator ID="rfvcandidate" runat="server" ControlToValidate="ddlcandidate" ErrorMessage="Please choose a candidate" InitialValue="Please choose a candidate"> </asp:RequiredFieldValidator> Required Field Validator
  • 10.  The CompareValidator control compares a value in one control with a fixed value, or, a value in another control.  It has the following specific properties: The basic syntax for the control: <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator"> </asp:CompareValidator> Compare Validator
  • 11.  The RangeValidator control verifies that the input value falls within a predetermined range.  It has three specific properties: The syntax for the control: <asp:RangeValidator ID="rvclass" runat="server" ControlToValidate="txtclass" ErrorMessage="Enter your class (6 - 12)" MaximumValue="12" MinimumValue="6" Type="Integer"> </asp:RangeValidator> Range Validator
  • 12.  The RegularExpressionValidator allows validating the input text by matching against a pattern against a regular expression. The regular expression is set in the ValidationExpression property.  The following table summarizes the commonly used syntax constructs for regular expressions: Regular Expression Validator <asp:RegularExpressionValidator ID="RegExpVal2" runat="server" ErrorMessage = "Please Enter Valid Email ID“ ValidationGroup="vgSubmit" ControlToValidate="txtEmail" CssClass="requiredFieldValidateStyle" ForeColor="Red" ValidationExpression="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*"> </asp:RegularExpressionValidator>
  • 13.  The CustomValidator control allows writing application specific custom validation routines for both the client side and the server side validation.  The server side validation routine should be written in any .Net language, like C# or VB.Net. The basic syntax for the control: <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction=.cvf_func. ErrorMessage="CustomValidator"></asp:CustomValidator> Custom Validator
  • 14.  The ValidationSummary control does not perform any validation but shows a summary of all errors in the page. The summary displays the values of the ErrorMessage property of all validation controls that failed validation.  Using Page.IsValid property we can check for page errors. When there are no errors IsValid returns true and user can proceed to next page. if (Page.IsValid) { //validation complete proceed } runat="server" The syntax for the control: <asp:ValidationSummary ID="ValidationSummary1" DisplayMode = "BulletList" ShowSummary = "true" HeaderText="Errors:" /> Validation Summary
  • 16. Validation Group Second problem = when I click the Login button, only fields in the Login section (Username & Password) needs to be validated. Along the same lines when I click the "Register" button, only fields in the Registration section(Email, Username, Password and ConfirmPassword) needs to validated. If we don't use validation groups, then by default, whenever, you click any button, all the validation controls on the page get validated. So, when you click the login button, and if you want only, the fields in the Login section(Username and Password) to be validated, then set, the Validationgroup property of the validation controls and the login button control to the same group name. Use a different group name for the validation controls and register button, in the registration section. First Problem: when I click the Clear button, Form validation still happens. When I click the clear button, I just want to clear the textboxes in the Registration section. Validations doesn't make any sense here. So, how do I prevent validation from happening? Answer: CausesValidation=“False”