tailieunhanh - asp net 2.0 all in one desk reference for Dummies PHẦN 10

Đó là một điều khiển DropDownList cho phép người dùng chọn một trong ba màu sắc. (Màu sắc bổ sung, như họ nói, còn lại là một bài tập cho người đọc.) Thêm một điều khiển người dùng Web được gọi là của bạn | 812 Connecting Web Parts Together As mentioned previously this function is specially equipped for use in data exchange. This time the added attribute is Connectionprovider Attribute which you probably guessed allows it to connect to another Web part as a data provider. Figure 5-18 shows the user control in Design view. It doesn t look like much now but it will be quite powerful by the time we ve finished with it. Figure 5-18 A user control calendar ready to connect Creating a connectable data provider Our third user control is also a data provider. It s a DropDownList control that lets the user choose one of three colors. Additional colors as they say are left as an exercise for the reader. 1. Add an Web user control called to your project making sure to use VB as the language and placing the code in a separate file. 2. From the toolbox drop a DropDownList control named DropDownList1 on the page. Add three items to the list so the markup looks like the following asp dropdownlist id DropDownList1 runat server autopostback True onselectedindexchanged DropDownList1_SelectedIndexChanged title Select Colour asp listitem Red asp listitem asp listitem Green asp listitem asp listitem Blue asp listitem asp dropdownlist Note that autopostback is set to True and onselectedindexchanged references a subroutine to handle the event. Connecting Web Parts Together 813 3. In the code behind file add the following code after the Inherits line Implements IColour Public Readonly Property SelectedColour As String _ Implements Get Return End Get End Property The preceding indicates that we are implementing the IColour class not created yet and its SelectedColour property. This is part of the conduit that provides the selected color value to another Web part on the page. 4. Add the GetSelectedColour function to pass along the color name by inserting the following code ConnectionProvider _ Selected

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.