Manning ASP.NET AJAX in Action PHẦN 2

Đối với nhân viên tra cứu logic, tạo ra một lớp đơn giản được gọi là , và chép đoạn code trong danh sách sách 1,7 Một lớp học đơn giản mà trả về số lượng nhân viên trong một bộ phận Hình 1,10 Các mẫu AJAX-Enabled Web Site tạo ra một trang web tham chiếu AJAX lắp ráp | Introducing AJAX 24 CHAPTER 1 Figure The AJAX-Enabled Web Site template creates a website that references the AJAX assembly and configures the file for Ajax integration. For the employee lookup logic create a simple class called and copy the code in listing . Listing A simple class that returns the number of employees in a department using System public static class HumanResources public static int GetEmployeeCount string department int count 0 switch department case Sales count 10 break case Engineering count 28 break case Marketing AJAX in action 25 count 44 break case HR count 7 break default break return count The HumanResources class contains one method GetEmployeeCount which takes the department name as a parameter. It uses a simple switch statement to retrieve the number of employees in the department. To keeps things simple we hardcoded the department names and values. When you created the new website a default page named was also generated. Listing shows the initial version of the page. Listing Default page created by the AJAX-Enabled Web Site template @ Page Language C AutoEventWireup true CodeFile Inherits _Default DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD html xmlns http 1999 xhtml head runat server title Untitled Page title head body ScriptManager form id form1 runat server control asp ScriptManager ID ScriptManager1 runat server --- div div form body html What s different in this page from the usual default page created by Visual Studio is the addition of the ScriptManager control. We briefly defined the ScriptManager earlier in the chapter as the brains of an Ajax-enabled page. In this example all you need to know about the ScriptManager is that it s required to Ajax-enable a 26 CHAPTER 1 Introducing AJAX page it s responsible for delivering the client-side scripts to 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
Đã 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.