TAILIEUCHUNG - ASP.NET 4 Unleased - p 178

Các dịch vụ web trong Ví dụ 39,2 bao gồm một phương thức web có tên là GetSuggestions () trả về một danh sách các tên tập tin phù hợp với tiền tố văn bản thông qua phương pháp web. Một truy vấn LINQ được sử dụng để trả về kết quả phù hợp. Lớp FileService được trang trí với một thuộc tính ScriptService. | 1744 CHAPTER 39 Using the AJAX Control Toolkit public string GetSuggestions string prefixText int count Directoryinfo dir new DirectoryInfo c windows return dir .GetFiles .Where f prefixText .Select f .ToArray The web service in Listing includes a web method named GetSuggestions that returns a list of filenames that match the prefix text passed to the web method. A LINQ query is used to return the matching results. The FileService class is decorated with a Scriptservice attribute. This attribute is required when exposing a web method to an Ajax request. If you don t include the Scriptservice attribute the web service cannot be called from the client side. The page in Listing contains an AutoComplete extender control that calls the web service. LISTING @ Page Language C @ Register TagPrefix ajax Namespace AjaxControlToolkit Assembly AjaxControlToolkit DOCTYPE html PUBLIC - W3C DTD XHTML Transitional EN http TR xhtml1 DTD script runat server protected void btnSubmit_Click object sender EventArgs e script html xmlns http 1999 xhtml head runat server title Show AutoComplete Web Service title head body form id form1 runat server div asp ScriptManager ID sm1 runat server From the Library of Wow eBook Using the AutoComplete Control 1745 asp Label id lblFileName Text File Name AssociatedControlID txtFileName Runat server asp TextBox id txtFileName AutoComplete off Runat server ajax AutoCompleteExtender id ace1 TargetControlID txtFileName ServiceMethod GetSuggestions ServicePath MinimumPrefixLength 1 runat server asp Button id btnSubmit Text Submit OnClick btnSubmit_Click Runat server br br asp Label id lblSelectedFileName runat server div form body html As you enter text into TextBox rendered by the page in Listing a list of matching filenames is retrieved by calling the GetSuggestions

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.