tailieunhanh - Pro Server Controls and AJAX Components phần 4

Để làm cho nó dễ dàng hơn để làm việc với các proxy dịch vụ web, chúng tôi quấn quá trình tạo và gọi bên trong một lớp tiện ích mà tóm tắt tất cả các chi tiết của giao tiếp với các dịch vụ web Live Search, như thể hiện trong Ví dụ 12-3. Lớp này cũng ẩn các công việc cần thiết để lấy thông tin cấu hình từ phần | 206 CHAPTER 5 SERVER CONTROL EVENTS Figure 5-10. The page after submitting the CustomEventTextBox web form The Visual Studio Properties window did its job in wiring up to the custom event. It was smart enough to realize we had to use TextChangedEventHandler as a delegate to wrap the NameCustom_TextChanged event-handling method. This behavior by the Designer is one more reason we recommend sticking to the event model design pattern implemented in .NET. As mentioned previously the resulting wire-up code appears in the .aspx page as an attribute on the server control apress CustomEventTextBox id NameCustom runat server OnTextChanged NameCustom_TextChanged apress CustomEventTextBox The following definition of NameCustom_TextChanged shows it is connected to TextChanged correctly taking TextChangedEventArgs as its second parameter. The parameter named tce is the conduit to the information added to the BeforeLabel and AfterLabel Text values private void NameCustom_TextChanged object o tce Figure 5-11 shows what happens if we type a second name in the CustomEventTextBox control input box and click the Submit Page button to generate another postback. The control successfully remembers what the previous input was. CHAPTER 5 SERVER CONTROL EVENTS 207 Figure 5-11. The second request with a new name on the CustomEventTextBox web form Capturing Postback with the Button Control The TextBox control does a great job in gathering input and raising state change events to their clients but sometimes we need controls that provide action and post data back to the server. A perfect example of this type of control in the framework is the . control. The Button control exists for one reason to post the page back to the server and raise events. We would be remiss if we only reverse-engineered the TextBox control and left out the Button control

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.