ASP.NET 4 Unleased - p 36

Creating Custom Controls with User Controls break; } } html { font:14px Arial,Sans-Serif; } Web Survey From the Library of Wow! eBook Dynamically Loading User Controls 325 | 324 CHAPTER 7 Creating Custom Controls with User Controls break script html xmlns http 1999 xhtml head id Head1 runat server style type text css html font 14px Arial Sans-Serif style title Web Survey title head body form id form1 runat server div asp Label id lblLanguage Text What language do you use to develop Web applications Runat server br asp DropDownList id ddlLanguage ToolTip Web application language reloads form AutoPostBack true Runat server asp ListItem Text Select Language asp ListItem Text ASP Classic asp ListItem Text asp DropDownList br br asp PlaceHolder id PlaceHolder1 Runat server asp Button id btnSubmit Text Submit OnClick btnSubmit_Click Runat server From the Library of Wow eBook Dynamically Loading User Controls 325 hr asp Literal id ltlResults Runat server div form body html WEB STANDARDS NOTE The DropDownList control in Listing reloads the page automatically when you select a new option. You should never reload a page without warning the user because this can be confusing for someone who uses an assistive device such as a screen reader. In Listing a warning is added to the ToolTip property of the DropDownList control. Depending on the user s selection from the DropDownList control one of two User controls is loaded in the Page_Load event handler or . These controls are contained in Listing and Listing . When you submit the survey form the btnSubmit_Click method executes. This method casts the User control loaded in the form to the correct type. It casts the User control to either the ASPSurvey or the ASPNetSurvey type. The page in Listing includes two @ Reference directives. These reference directives enable you to cast the User control to the correct type so that you can access custom properties of the control such as the KnowSlow and KnowOutdated properties. 7 LISTING @ Control Language C ClassName ASPSurvey script runat server public bool KnowSlow

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
Đã 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.