Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 1.1 Insider Solutions- P5
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'asp.net 1.1 insider solutions- p5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 188 5 Creating Reusable Content LISTING 5.26 Continued dropbox.CssClass CssClass.ToString textbox2.CssClass CssClass.ToString End If dropbox.Attributes.Add onclick selectList sCID dropbox1 textbox2 textbox2.Attributes.Add onkeyup scrollList sCID dropbox1 textbox2 dropbtn.Attributes.Add onclick return openList _ sCID dropbox.DataSource DataSource dropbox.DataTextField DataTextField dropbox.DataTextFormatString DataTextFormatString dropbox.DataBind Else pchStandard.Visible True If CssClass Then listbox.CssClass CssClass textbox.CssClass CssClass End If listbox.Attributes.Add onclick selectList sCID listbox textbox textbox.Attributes.Add onkeyup scrollList sCID listbox textbox listbox.DataSource DataSource listbox.DataTextField DataTextField listbox.DataTextFormatString DataTextFormatString listbox.DataBind End If SetWidth SetRows End Sub Now you can apply any CSS classname that may have been specified for the CssClass property to both the list and text box. Then you add the attributes to the text box and list that attach the client-side script functions. You use the complete ID of this instance of the user control which you generated earlier and specify the appropriate text box and list control IDs. If you re creating a drop-down combo box you also have to connect the openList function to the list control. Next you set the data binding properties of the list within the user control to the values specified for the matching properties of the user control and call the DataBind method. In fact you could check whether the DataSource property has been set first before setting the properties and Using the ComboBox Control 189 calling DataBind. This would probably be marginally more efficient although the DataBind method does nothing if the DatSource property is empty. Finally you call the SetWidth and SetRows routines again to ensure that any conflicting CSS styles are removed from the constituent controls. And that s it the ComboBox control is complete and ready to go. You