Wrox Professional Web Parts and Custom Controls with ASP.NET 2.0 phần 8

Trình dịch JIT cung cấp thêm khả năng bảo mật, tính an toàn lúc thực thi và khả năng chạy trên nhiều nền tảng (Microsoft cho biết sẽ dùng một tập con chuẩn hoá của .NET Framework - được gọi là nền tảng ngôn ngữ chung” - để xây dựng một thể hiện trên FreeBSD). Nếu trình JIT cho mã ngôn ngữ trung gian làm bạn liên tưởng đến Java thì cũng đừng hoang mang, Microsoft đã lẳng lặng dùng ngôn ngữ trung gian trong Vbasic và hầu hết các phần mềm ứng dụng của mình (kể cả Office)từ nhiều. | Chapter 9 Private _ChildControls As ArrayList Public Property ChildControls As ArrayList Get Return _ChildControls End Get Set ByVal value As ArrayList _ChildControls value End Set End Property In C private ArrayList _ChildControls public ArrayList ChildControls get return _ChildControls set _ChildControls value On the class declaration you must specify this repository property as the default property for your control as this Visual Basic 2005 code does ParseChildren True ChildControls _ ToolboxData 0 BookInfo runat server 0 BookInfo _ Public Class BookInfo In C ParseChildren true ChildControls ToolboxData 0 BookInfo runat server 0 BookInfo public class BookInfo In your Render method you could iterate through the ChildControls collection having each control render itself by calling its RenderControl method. In Visual Basic 2005 the code looks like this Protected Overrides Sub Render ByVal writer As For Each ctl As Control In writer Next End Sub In C protected override void Render writer foreach Control ctl in 298 Adding Advanced Functionality writer While this provides a simple mechanism for generating constituent controls it doesn t really address the issue of handling multiple properties with complex datatypes. Instead it creates a single property to hold all complex objects. It is better to have a dedicated property for each object. It is also better to have some mechanism that allows you to manage the processing of the tags nested in the custom control rather than just blindly rendering them. Handling Complex Content The next step is to handle multiple complex properties on a single control and provide a mechanism for managing those elements as they are added. As the example for this section the BookInfo control is extended to support the following nested tags The Author tag with a first name and a last name The Titles tag with the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
264    58    2    20-05-2024
Đã 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.