Beginning Ajax with ASP.NET- P16
Số trang: 15
Loại file: pdf
Dung lượng: 406.81 KB
Lượt xem: 14
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Beginning Ajax with ASP.NET- P16:Thank you for purchasing Beginning Ajax with ASP.NET. We know that you have a lot of options whenselecting a programming book and are glad that you have chosen ours. We’re sure you will be pleasedwith the relevant content and high quality you have come to expect from the Wrox Press line of books.
Nội dung trích xuất từ tài liệu:
Beginning Ajax with ASP.NET- P16 Other Ajax Frameworks for .NET The framework contains supporting code to trap events where the user clicks on a link that points to another HTML document on the server. The click event is interrogated by the custom method, and if it con- tains a “class” attribute that matches the format described previously (that is, loadinto-{control_id}), then an asynchronous operation is invoked to perform the document loading and subsequent dynamic displaying on the web browser display. Currently, this framework is ideally suited to constructing HTML pages using multiple content sources located on a server and loaded in asynchronously so that links never actually cause a postback to occur. As of this writing, experimental modifications allow post-ing a form asynchronously to a server and receiving a result, which is also dynamically displayed. This is, however, not fully tested and is a work in progress. If the display of an HTML file using dynamic and asynchronous behavior is desired, then this library can be easily and effectively used to achieve that. If access to specific server-side services is required above and beyond that of simple HTML document display, then this library may not be the ideal choice. If nothing else, the ability of this library to capture events easily can be used to perform any number of tasks not currently offered by the framework.MochiKit URL: http://mochikit.com MochiKit is a client-side JavaScript framework or more specifically, a suite of JavaScript libraries. MochiKit is described as (taken from the web site itself) a suite of JavaScript libraries that “make JavaScript suck less.” The aim of the MochiKit framework is to make programming in JavaScript a lot easier and, like many of the other client-side-only libraries, provide a layer of abstraction between raw coding details that are specific to each browser. This allows a common method of accessing objects and functions, such as Ajax asynchronous functionality, without having to code specific implementations for all the browsers you are required to support in your development efforts. MochiKit is quite a comprehensive framework and contains a large amount of functionality that extends asynchronous behavior. Broadly speaking, MochiKit covers the following areas: ❑ Asynchronous requests ❑ Low-level functional and comparison features ❑ DOM manipulation ❑ Color and style manipulation with CSS3 (Cascading Style Sheets) support ❑ Date and time formatting and parsing routines ❑ String formatting routines ❑ Logging features and supporting an API ❑ Specialized Logging Pane to aid in tracing and debugging ❑ Visual effects library ❑ Iteration support API 201Chapter 9 Each one of the areas listed is contained within a separate module of the MochiKit framework. Simplicity is a key goal with this framework and some examples best demonstrate this: var x = getXMLHttpRequest(); The preceding code will simply return an object that is the equivalent XMLHttpRequest object for the particular platform (that is, browser type): var d = loadJSONDoc(url): This code will perform an asynchronous request to the specified URL location and retrieve the response as a JSON-formatted document. JSON is an acronym for the JavaScript Object Notation and is a stan- dard, lightweight way of representing objects using a string format. JavaScript natively understands this format and can evaluate a string that is in JSON format using the eval method to return a valid object. The loadJSONDoc method shown in the preceding code line returns an object that is of type Deferred. The Deferred object is a special type provided by the MochiKit library. Deferred type objects are a way of abstracting nonblocking events, such as the final response to an XMLHttpRequest. These allow the addition of callback functions to the Deferred objects collection that are called when an asynchronous operation completes. The complete code might look like this: var d = loadJSONDoc(“http://www.yourhost.com/somedocument.json”); var gotMetadata = function (meta) { alert(“JSON document loaded ok.”); }; var metadataFetchFailed = function (err) { alert(“The document could not be fetched.”); }; d.addCallbacks(gotMetadata, metadataFetchFailed); The first line of the preceding example: var d = loadJSONDoc(“http://www.yourhost.com/somedocument.json”); simply instructs the MochiKit library to asynchronously load the document specified and returns an instance of an object that is of type Deferred. The next two lines define functions that you want to be called when the document loads successfully and when an error occurs, respectively. var gotMetadata = function (meta) { alert(“JSON document loaded ok.”); }; var metadataFetchFailed = function (err) { alert(“The document could not be fetched.”); }; It is then a matter of attaching these functions to the Deferred object that is returned using the syntax: d.addCallbacks(gotMetadata, metadataFetchFailed); The Deferred object is a fundamental part of the MochiKit framework and provides much more exten- sive functionality than what has been listed here to support a wide variety of asynchronous operations,202 Other Ajax Frameworks for .NET locking, synchronization, callbacks, and so on. In many ways, the Deferred object provides similar fea- tures, or at least provides a similar function, to delegates within the .NET framework. In addition to support for asynchronous behav ...
Nội dung trích xuất từ tài liệu:
Beginning Ajax with ASP.NET- P16 Other Ajax Frameworks for .NET The framework contains supporting code to trap events where the user clicks on a link that points to another HTML document on the server. The click event is interrogated by the custom method, and if it con- tains a “class” attribute that matches the format described previously (that is, loadinto-{control_id}), then an asynchronous operation is invoked to perform the document loading and subsequent dynamic displaying on the web browser display. Currently, this framework is ideally suited to constructing HTML pages using multiple content sources located on a server and loaded in asynchronously so that links never actually cause a postback to occur. As of this writing, experimental modifications allow post-ing a form asynchronously to a server and receiving a result, which is also dynamically displayed. This is, however, not fully tested and is a work in progress. If the display of an HTML file using dynamic and asynchronous behavior is desired, then this library can be easily and effectively used to achieve that. If access to specific server-side services is required above and beyond that of simple HTML document display, then this library may not be the ideal choice. If nothing else, the ability of this library to capture events easily can be used to perform any number of tasks not currently offered by the framework.MochiKit URL: http://mochikit.com MochiKit is a client-side JavaScript framework or more specifically, a suite of JavaScript libraries. MochiKit is described as (taken from the web site itself) a suite of JavaScript libraries that “make JavaScript suck less.” The aim of the MochiKit framework is to make programming in JavaScript a lot easier and, like many of the other client-side-only libraries, provide a layer of abstraction between raw coding details that are specific to each browser. This allows a common method of accessing objects and functions, such as Ajax asynchronous functionality, without having to code specific implementations for all the browsers you are required to support in your development efforts. MochiKit is quite a comprehensive framework and contains a large amount of functionality that extends asynchronous behavior. Broadly speaking, MochiKit covers the following areas: ❑ Asynchronous requests ❑ Low-level functional and comparison features ❑ DOM manipulation ❑ Color and style manipulation with CSS3 (Cascading Style Sheets) support ❑ Date and time formatting and parsing routines ❑ String formatting routines ❑ Logging features and supporting an API ❑ Specialized Logging Pane to aid in tracing and debugging ❑ Visual effects library ❑ Iteration support API 201Chapter 9 Each one of the areas listed is contained within a separate module of the MochiKit framework. Simplicity is a key goal with this framework and some examples best demonstrate this: var x = getXMLHttpRequest(); The preceding code will simply return an object that is the equivalent XMLHttpRequest object for the particular platform (that is, browser type): var d = loadJSONDoc(url): This code will perform an asynchronous request to the specified URL location and retrieve the response as a JSON-formatted document. JSON is an acronym for the JavaScript Object Notation and is a stan- dard, lightweight way of representing objects using a string format. JavaScript natively understands this format and can evaluate a string that is in JSON format using the eval method to return a valid object. The loadJSONDoc method shown in the preceding code line returns an object that is of type Deferred. The Deferred object is a special type provided by the MochiKit library. Deferred type objects are a way of abstracting nonblocking events, such as the final response to an XMLHttpRequest. These allow the addition of callback functions to the Deferred objects collection that are called when an asynchronous operation completes. The complete code might look like this: var d = loadJSONDoc(“http://www.yourhost.com/somedocument.json”); var gotMetadata = function (meta) { alert(“JSON document loaded ok.”); }; var metadataFetchFailed = function (err) { alert(“The document could not be fetched.”); }; d.addCallbacks(gotMetadata, metadataFetchFailed); The first line of the preceding example: var d = loadJSONDoc(“http://www.yourhost.com/somedocument.json”); simply instructs the MochiKit library to asynchronously load the document specified and returns an instance of an object that is of type Deferred. The next two lines define functions that you want to be called when the document loads successfully and when an error occurs, respectively. var gotMetadata = function (meta) { alert(“JSON document loaded ok.”); }; var metadataFetchFailed = function (err) { alert(“The document could not be fetched.”); }; It is then a matter of attaching these functions to the Deferred object that is returned using the syntax: d.addCallbacks(gotMetadata, metadataFetchFailed); The Deferred object is a fundamental part of the MochiKit framework and provides much more exten- sive functionality than what has been listed here to support a wide variety of asynchronous operations,202 Other Ajax Frameworks for .NET locking, synchronization, callbacks, and so on. In many ways, the Deferred object provides similar fea- tures, or at least provides a similar function, to delegates within the .NET framework. In addition to support for asynchronous behav ...
Tìm kiếm theo từ khóa liên quan:
nhập môn lập trình kỹ thuật lập trình lập trình flash lập trình web ngôn ngữ html lập trình hướng đối tượngGợi ý tài liệu liên quan:
-
Đề cương chi tiết học phần Cấu trúc dữ liệu và giải thuật (Data structures and algorithms)
10 trang 301 0 0 -
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 254 0 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 244 0 0 -
101 trang 193 1 0
-
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 179 0 0 -
Giới thiệu môn học Ngôn ngữ lập trình C++
5 trang 177 0 0 -
Luận văn: Nghiên cứu kỹ thuật giấu tin trong ảnh Gif
33 trang 146 0 0 -
Bài giảng Nhập môn về lập trình - Chương 1: Giới thiệu về máy tính và lập trình
30 trang 142 0 0 -
Giáo trình nhập môn lập trình - Phần 22
48 trang 135 0 0 -
14 trang 128 0 0