Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Việc kiểm soát trong Ví dụ 36,6 ám đằng sau một bóng thả bất cứ văn bản mà bạn chỉ định cho tài sản của văn bản điều khiển (xem hình 36,3). Các hiệu ứng bóng đổ được tạo ra với sự giúp đỡ của một Internet Explorer DropShadow lọc. | 1584 CHAPTER 36 Building Custom Controls The control in Listing 36.6 renders a drop shadow behind whatever text you assign to the control s Text property see Figure 36.3 . The drop shadow is created with the help of an Internet Explorer DropShadow filter. FIGURE 36.3 Displaying a drop shadow with the DropShadow control. The Filter attribute is added to the div tag with a call to the AddStyleAttribute method. The AddStyleAttribute method works just like the AddAttribute method except that the AddStyleAttribute method adds a CSS attribute instead of an HTML attribute. WEB STANDARDS NOTE Filters are an Internet Explorer extension to the CSS standard. They don t work with Firefox or Opera. Firefox has its own extensions to CSS with its -moz style rules. Specifying the Containing WebControl Tag By default a WebControl renders an HTML span tag around its contents. You can specify a different tag by overriding the WebControl s TagKey property. For example the control in Listing 36.7 renders its contents within an HTML div tag. From the Library of Wow eBook Overview of Custom Control Building 1585 LISTING 36.7 Glow.cs using System.Web.UI using System.Web.UI.WebControls namespace myControls public class Glow WebControl private string _Text public string Text get return _Text set _Text value protected override HtmlTextWriterTag TagKey get return HtmlTextWriterTag.Div protected override void AddAttributesToRender HtmlTextWriter writer writer.AddStyleAttribute HtmlTextWriterStyle.Filter glow Color ffd700 Strength 10 base.AddAttributesToRender writer protected override void RenderContents HtmlTextWriter writer writer.Write _Text public Glow this.Width Unit.Parse 500px 36 From the Library of Wow eBook 1586 CHAPTER 36 Building Custom Controls The control in Listing 36.7 displays a glowing effect around any text that you assign to its Text property. The control takes advantage of the Internet Explorer Glow filter to create the glow effect see Figure 36.4 . In a real production .