tailieunhanh - ASP.NET 4 Unleased - p 10
Khi bạn cung cấp một điều khiển Label với một tài sản AssociatedControlID, điều khiển Label là ra như là một tag HTML thay vì một tag HTML . Ví dụ, nếu bạn chọn View Source trên trình duyệt web của bạn, bạn thấy rằng các nhãn đầu tiên trong danh mục 2,3 làm cho nội dung sau đây để trình duyệt: | 64 CHAPTER 2 Using the Standard Controls title Label Form title head body form id form1 runat server div asp Label id lblFirstName Text First Name AssociatedControlID txtFirstName Runat server br asp TextBox id txtFirstName Runat server br br asp Label id lblLastName Text Last Name AssociatedControlID txtLastName Runat server br asp TextBox id txtLastName Runat server div form body html When you provide a Label control with an AssociatedControlID property the Label control is rendered as an HTML label tag instead of an HTML span tag. For example if you select View Source on your web browser you see that the first Label in Listing renders the following content to the browser label for txtFirstName id lblFirstName First Name label Always use a Label control with an AssociatedControlID property when labeling form fields. This is important when you need to make your website accessible to persons with disabilities. If someone uses an assistive device such as a screen reader to interact with your website the AssociatedControlID property enables the assistive device to associate the correct label with the correct form field. From the Library of Wow eBook Displaying Information 65 A side benefit of using the AssociatedControlID property is that clicking a label when this property is set automatically changes the form focus to the associated form input field. WEB STANDARDS NOTE Both the WCAG and Section 508 accessibility guidelines require you to use the label for tag when labeling form fields. For more information see http . org wai and http . 2 Using the Literal Control The Literal control is similar to the Label control. You can use the Literal control to display text or HTML content in a browser. However unlike the Label control the Literal control does not render its content inside of a span tag. For example the page in Listing uses a Literal control in the page s head tag to dynamically modify the title displayed in the browser .
đang nạp các trang xem trước