TAILIEUCHUNG - Lập trình .net 4.0 và visual studio 2010 part 40

Tất nhiên, khi bạn đang liên kết với dữ liệu, bạn thường muốn lấy nó từ một nguồn bên ngoài. Việc kiểm soát DataView cho phép bạn dễ dàng thực hiện việc này và liên kết với nhiều loại khác nhau của dịch vụ, ví dụ: • ASMX web dịch vụ • các dịch vụ web WCF • Dịch vụ dữ liệu WCF • MVC điều khiển hành động • JSONP dịch vụ • Về cơ bản bất cứ điều gì mà trả về JSON định dạng dữ liệu Bây giờ bạn sẽ sử dụng các mẫu để khách hàng liên kết với cả một ASMX. | CHAPTER 11 MICROSOFT AJAX LIBRARY Binding to External Services Of course when you are binding to data you usually want to retrieve it from an external source. The DataView control allows you to very easily accomplish this and bind to many different types of services for example ASMX web service WCF web services WCF Data Services MVC controller actions JSONP service Basically anything that returns JSON-formatted data You will now use client templates to bind to both an ASMX and WCF web service. WebService .asmx First the web service 1. Add a new class called Person to the project and enter the following class definition public class Person public string Name get set public string Age get set 2. Add a new .asmx web service to the project called . 3. Add the following using directive to using 4. Uncomment the following attribute in the GetData class 5. Now create a new method to return a list of people. Note the call to it slows down the service so you can see the results appear you might want to remove the systemplate style to see the effect latency can have WebMethod public List Person GetPeople 2000 List Person People new List Person new Person Name Alex Mackey Age 28 new Person Name Matt Lacey Age 31 new Person Name Barry Dorrans Age 78 262 CHAPTER 11 MICROSOFT AJAX LIBRARY new Person Name Craig Murphy Age 33 new Person Name Chris Hay Age 32 new Person Name Andy Gibson Age 21 return People 6. Copy the file and rename the new copy as . 7. Replace the existing script block with the following code script type text javascript function peopleView dataProvider fetchoperation .

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