![Phân tích tư tưởng của nhân dân qua đoạn thơ: Những người vợ nhớ chồng… Những cuộc đời đã hóa sông núi ta trong Đất nước của Nguyễn Khoa Điềm](https://timtailieu.net/upload/document/136415/phan-tich-tu-tuong-cua-nhan-dan-qua-doan-tho-039-039-nhung-nguoi-vo-nho-chong-nhung-cuoc-doi-da-hoa-song-nui-ta-039-039-trong-dat-nuoc-cua-nguyen-khoa-136415.jpg)
Validate Data Using Validation Controls
Số trang: 6
Loại file: pdf
Dung lượng: 35.27 KB
Lượt xem: 5
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Xác nhận dữ liệu Sử dụng điều khiển Xác Nhận Tôi muốn để có thể xác nhận các loại hình nhập dữ liệu mà không cần phải chờ đợi cho một lỗi trở về từ máy chủ. Tôi có thể xác nhận dữ liệu của tôi trên Form Web của tôi?
Nội dung trích xuất từ tài liệu:
Validate Data Using Validation Controls 5.2 Validate Data Using Validation ControlsI want to be able to validate various types of data entry without having to wait for anerror to come back from the server. Can I validate my data on my Web Form?Note A note of caution: Through the writing and tech editing of this chapter, there have been some inconsistencies noted in the reaction of some of the validator controls. The tech editor and I both contend that this area might have some .NET bugs. This is also the reason for the lack of coverage in the CustomValidator.TechniqueOne new feature found in ASP.NET is the inclusion of Validation Web server controls.These validation controls allow you to specify other controls of which you want tovalidate based on data entered into the controls. You can then do the following: • Have the Validation control display an error message. • Test at a page level to see if all controls that are being validated are valid. • Display a list of error messages for all the controls that are being validated.Available Validation Web Server ControlsYou will find the controls for validation in the toolbox, and can see them listed in Table5.2, with a description of what they validate. Table 5.2. Validation Web Server ControlsControl DescriptionRequiredFieldValidator Validates whether the specified control has been left blank.CompareValidator Compares the values in two controls and validates whether they are equal.RangeValidator Checks to see if the value entered into a control falls within a range that is specified.RegularExpressionValidator Compares a value entered into a control to see if it matches an entered mask, such as 999-99-9999, which is the U.S. Social Security Number.CustomValidator Allows you to create custom functions on both the client and server side for validation.ValidationSummary Used to consolidate the messages that all validation controls return on a page into a list-like format.The main properties you will set on a validation control are FieldToValidate andErrorMessage.Note The CustomValidator control is different in that you will create functions to perform the validation. Other than these, the validation controls require no coding unless you want to validate the whole page.Testing Page Validation in CodeDepending on what is required, you can test for validation at the page level using thePage.Validate method. When you call this method, all the Validation controls areretested, and the Page.IsValid property is set. You can use the IsValid property in acondition statement to perform tasks based on the value of the IsValid property, as shownin the last step of this How-To.StepsOpen and run the Visual Basic .NET-Chapter 5 solution. From the main page, click onthe hyperlink with the caption How-To 5.2: Validate Data Using Validation Controls.When the Web Form loads, you will see a number of text boxes with instructions on howto see the various validation checks. Here is the Web Form in Design view (see Figure5.2). 1. Create a Web Form. Then place the controls listed in Table 5.3 and shown in Figure 5.2 with the following properties set. Table 5.3. Control Property Settings for Validation Controls Web Form Object Property Setting Label Text Required Field Validator Example (Leave Blank to Test)TextBox ID txtRequiredExampleLabel Text Compare Validator Example (Enter Two Different Values in These Text Boxes)TextBox ID txtCompareFirstTextBox ID txtCompareSecondLabel Text Range Validator Example (Enter a Number Outside the Range 1 and 10)TextBox ID txtRangeExampleLabel Text Regular Expression Validator Example (Enter a SSN not matching 999-99- 9999)TextBox ID txtRegularExprExampleLabel Text Custom Validator Example (Enter a State Other Than WA or CA)TextBox ID txtCustomExampleButton ID btnTestValidators Text Test ValidatorsLabel Text Page Validation ErrorsRequiredFieldValidator ToValidate txtRequiredExampleControl ErrorMessage Here is the message for the Required Field ValidatorCompareValidator ControlToCompare txtCompareFirst ControlToValidate txtCompareSecond ErrorMessage Here is the message for the Compare ValidatorRangeValidator ControlTo ...
Nội dung trích xuất từ tài liệu:
Validate Data Using Validation Controls 5.2 Validate Data Using Validation ControlsI want to be able to validate various types of data entry without having to wait for anerror to come back from the server. Can I validate my data on my Web Form?Note A note of caution: Through the writing and tech editing of this chapter, there have been some inconsistencies noted in the reaction of some of the validator controls. The tech editor and I both contend that this area might have some .NET bugs. This is also the reason for the lack of coverage in the CustomValidator.TechniqueOne new feature found in ASP.NET is the inclusion of Validation Web server controls.These validation controls allow you to specify other controls of which you want tovalidate based on data entered into the controls. You can then do the following: • Have the Validation control display an error message. • Test at a page level to see if all controls that are being validated are valid. • Display a list of error messages for all the controls that are being validated.Available Validation Web Server ControlsYou will find the controls for validation in the toolbox, and can see them listed in Table5.2, with a description of what they validate. Table 5.2. Validation Web Server ControlsControl DescriptionRequiredFieldValidator Validates whether the specified control has been left blank.CompareValidator Compares the values in two controls and validates whether they are equal.RangeValidator Checks to see if the value entered into a control falls within a range that is specified.RegularExpressionValidator Compares a value entered into a control to see if it matches an entered mask, such as 999-99-9999, which is the U.S. Social Security Number.CustomValidator Allows you to create custom functions on both the client and server side for validation.ValidationSummary Used to consolidate the messages that all validation controls return on a page into a list-like format.The main properties you will set on a validation control are FieldToValidate andErrorMessage.Note The CustomValidator control is different in that you will create functions to perform the validation. Other than these, the validation controls require no coding unless you want to validate the whole page.Testing Page Validation in CodeDepending on what is required, you can test for validation at the page level using thePage.Validate method. When you call this method, all the Validation controls areretested, and the Page.IsValid property is set. You can use the IsValid property in acondition statement to perform tasks based on the value of the IsValid property, as shownin the last step of this How-To.StepsOpen and run the Visual Basic .NET-Chapter 5 solution. From the main page, click onthe hyperlink with the caption How-To 5.2: Validate Data Using Validation Controls.When the Web Form loads, you will see a number of text boxes with instructions on howto see the various validation checks. Here is the Web Form in Design view (see Figure5.2). 1. Create a Web Form. Then place the controls listed in Table 5.3 and shown in Figure 5.2 with the following properties set. Table 5.3. Control Property Settings for Validation Controls Web Form Object Property Setting Label Text Required Field Validator Example (Leave Blank to Test)TextBox ID txtRequiredExampleLabel Text Compare Validator Example (Enter Two Different Values in These Text Boxes)TextBox ID txtCompareFirstTextBox ID txtCompareSecondLabel Text Range Validator Example (Enter a Number Outside the Range 1 and 10)TextBox ID txtRangeExampleLabel Text Regular Expression Validator Example (Enter a SSN not matching 999-99- 9999)TextBox ID txtRegularExprExampleLabel Text Custom Validator Example (Enter a State Other Than WA or CA)TextBox ID txtCustomExampleButton ID btnTestValidators Text Test ValidatorsLabel Text Page Validation ErrorsRequiredFieldValidator ToValidate txtRequiredExampleControl ErrorMessage Here is the message for the Required Field ValidatorCompareValidator ControlToCompare txtCompareFirst ControlToValidate txtCompareSecond ErrorMessage Here is the message for the Compare ValidatorRangeValidator ControlTo ...
Tìm kiếm theo từ khóa liên quan:
công nghệ máy tính phần mềm kỹ thuật lập trình dữ liệu Validation ControlsTài liệu liên quan:
-
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 283 0 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 225 0 0 -
Giới thiệu môn học Ngôn ngữ lập trình C++
5 trang 208 0 0 -
6 trang 206 0 0
-
Bài giảng Nhập môn về lập trình - Chương 1: Giới thiệu về máy tính và lập trình
30 trang 179 0 0 -
Luận văn: Nghiên cứu kỹ thuật giấu tin trong ảnh Gif
33 trang 156 0 0 -
Báo cáo thực tập Công nghệ thông tin: Lập trình game trên Unity
27 trang 122 0 0 -
Giáo trình về phân tích thiết kế hệ thống thông tin
113 trang 114 0 0 -
LUẬN VĂN: Tìm hiểu kỹ thuật tạo bóng cứng trong đồ họa 3D
41 trang 111 0 0 -
Bài giảng Kỹ thuật lập trình - Chương 10: Tổng kết môn học (Trường Đại học Bách khoa Hà Nội)
67 trang 109 0 0