TAILIEUCHUNG - ASP.NET 4 Unleased - p 14

Hiển thị hình ảnh Khung bao gồm hai điều khiển để hiển thị hình ảnh: Hình ảnh và Imagemap. Việc kiểm soát hình ảnh đơn giản chỉ hiển thị một hình ảnh. Việc kiểm soát Imagemap cho phép bạn tạo một máy khách, có thể click được, hình ảnh bản đồ. | 104 CHAPTER 2 Using the Standard Controls FIGURE Handling the Command event. Displaying Images The Framework includes two controls for displaying images Image and ImageMap. The Image control simply displays an image. The ImageMap control enables you to create a client-side clickable image map. Using the Image Control The page in Listing randomly displays one of three images. The image is displayed by setting the ImageUrl property of the Image control contained in the body of the page. LISTING @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML Transitional EN http TR xhtml1 DTD script runat server void Page_Load Random rnd new Random switch 3 From the Library of Wow eBook Displaying Images 105 case 0 Picture 1 break case 1 Picture 2 break case 2 Picture 3 break script html xmlns http 1999 xhtml head id Head1 runat server title Show Image title head body form id form1 runat server div 2 asp Image id imgRandom Runat server div form body html The Image control supports the following properties this is not a complete list AlternateText Enables you to provide alternate text for the image required for accessibility . DescriptionUrl Enables you to provide a link to a page that contains a detailed description of the image required to make a complex image accessible . GenerateEmptyAlternateText Enables you to set the AlternateText property to an empty string. From the Library of Wow eBook 106 CHAPTER 2 Using the Standard Controls ImageAlign Enables you to align the image relative to other HTML elements in the page. Possible values are AbsBottom AbsMiddle Baseline Bottom Left Middle NotSet Right TextTop and Top. ImageUrl Enables you to specify the URL to the image. The Image control supports three methods for .