TAILIEUCHUNG - ASP.NET 4 Unleased - p 169

Building Templated Databound Controls (lblTitle); (new LiteralControl(“”)); (lblAuthor); (new LiteralControl(“”)); (lblContents); } void lblTitle_DataBinding(object sender, EventArgs e) { Label lblTitle = (Label)sender; ArticleWithDefault container = ➥(ArticleWithDefault); = ; } void lblAuthor_DataBinding(object sender, EventArgs e) { Label lblAuthor = (Label)sender; ArticleWithDefault container = ➥(ArticleWithDefault); = ; } void lblContents_DataBinding(object sender, EventArgs e) { Label lblContents = (Label)sender; ArticleWithDefault container = ➥(ArticleWithDefault); = ; } } } The control in Listing is similar to the control created in the previous. | 1654 CHAPTER 37 Building Templated Databound Controls lblTitle new LiteralControl br lblAuthor new LiteralControl br lblContents void lblTitle_DataBinding object sender EventArgs e Label lblTitle Label sender ArticleWithDefault container ArticleWithDefault void lblAuthor_DataBinding object sender EventArgs e Label lblAuthor Label sender ArticleWithDefault container ArticleWithDefault void lblContents_DataBinding object sender EventArgs e Label lblContents Label sender ArticleWithDefault container ArticleWithDefault The control in Listing is similar to the control created in the previous section however the CreateChildControls method has been modified. The new version of the CreateChildControls method tests whether there is an ItemTemplate. If no ItemTemplate exists an instance of the ArticleDefaultTemplate class is created. The ArticleDefaultTemplate class which is also included in Listing implements the ITemplate interface. In particular the class implements the InstantiateIn method which creates all the controls that appear in the template. In Listing three Label controls are created that correspond to the Title Author and Contents properties. The DataBinding event is handled for all three of these Label From the Library of Wow eBook Creating Templated Controls 1655 controls. When the DataBind method is called the DataBinding event is raised for each child control in the Article control. At that time the values of the Title Author and Contents properties are assigned to the Text properties of the Label controls. The page in Listing illustrates how you can use the modified Article control. LISTING @ Page Language C @ Register

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.