Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 4 Unleased - p 20

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Nếu bạn nộp đơn trong Ví dụ 3,18 mà không cần nhập một giá trị cho tên đầu tiên và cuối cùng, xác nhận các thông báo lỗi xuất hiện trong cơ thể cả hai trang và trong việc kiểm soát ValidationSummary. Việc kiểm soát ValidationSummary hỗ trợ các thuộc tính sau:. DisplayMode-Cho phép bạn chỉ định cách các thông báo lỗi được định dạng. | 164 CHAPTER 3 Using the Validation Controls id txtLastName Runat server asp RequiredFieldValidator id reqLastName Text Required ErrorMessage Last Name is required ControlToValidate txtLastName Runat server br br asp Button id btnSubmit Text Submit Runat server div form body html FIGURE 3.14 Displaying a validation summary. From the Library of Wow eBook Using the Validationsummary Control 165 If you submit the form in Listing 3.18 without entering a value for the first and last name validation error messages appear in both the body of the page and in the Validationsummary control. The Validationsummary control supports the following properties DisplayMode Enables you to specify how the error messages are formatted. Possible values are BulletList List and SingleParagraph. HeaderText Enables you to display header text above the validation summary. ShowMessageBox Enables you to display a pop-up alert box. ShowSummary Enables you to hide the validation summary in the page. If you set the ShowMessageBox property to the value True and the ShowSummary property to the value False you can display the validation summary only within a pop-up alert box. For example the page in Listing 3.19 displays a validation summary in an alert box see Figure 3.15 . LISTING 3.19 ShowSummaryPopup.aspx 3 @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML 1.0 Transitional EN http www.w3.org TR xhtml1 DTD xhtml1-transitional.dtd html xmlns http www.w3.org 1999 xhtml head id Head1 runat server title Show Summary Popup title head body form id form1 runat server div asp ValidationSummary id ValidationSummary1 ShowMessageBox true ShowSummary false Runat server asp Label id lblFirstName Text First Name AssociatedControlID txtFirstName Runat server br asp TextBox id txtFirstName Runat server From the Library of Wow eBook 166 CHAPTER 3 Using the Validation Controls asp RequiredFieldValidator id reqFirstName ErrorMessage First Name is required ControlToValidate txtFirstName Display None Runat server

TÀI LIỆU LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.