Beginning Ajax with ASP.NET- P13
Số trang: 15
Loại file: pdf
Dung lượng: 369.96 KB
Lượt xem: 9
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- P13: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- P13Chapter 6 The {1} placeholder represents the: “WebForm_InitCallback()” JavaScript code, which collects and prepares the form data to post to the server for the callback to the server to be correctly interpreted and trapped by the ASP.NET runtime engine. This is crucial so that the correct server-side methods are executed in response to the callback event as expected. Finally, the {2} placeholder represents the code: Page.ClientScript.GetCallbackEventReference( this, arg, “MyControl_Callback”, “null”)); This code should look familiar, and is the same method used to obtain a callback event reference in the initial page-centric examples detailed previously in the discussion of the ICallbackEventHandler interface. It is used for exactly the same purpose here, as the final step to initiate the asynchronous call- back request to the server. To summarize, the implementation of the ICallbackContainer method first constructs the arguments to send to the server-side callback request and returns a JavaScript block that first clears the posted data, initializes the collection of the posted data in the HTTP request (via WebForm_InitCallback() ), and finally initiates the callback request by obtaining the callback event through the Page.GetCallbackEventReference method. This section is not intended as a complete discussion on the specifics of implementing asynchronous callback functionality within your custom controls, but merely serves as an introduction on how to begin such a task with asynchronous callbacks in mind. The reader is encouraged to perform further investiga- tion in this advanced topic area and in particular in the creation of custom controls.Summar y This chapter has introduced the concept of Asynchronous Callback Client Scripts that are provided with ASP.NET 2.0. This feature allows a developer to utilize Ajax-like functionality within ASP.NET in a num- ber of ways. You looked at how you could include asynchronous callbacks in your applications by: ❑ Using “out-of-the-box” server controls that come included with ASP.NET ❑ Implementing the requisite interfaces to enable your pages to support asynchronous behavior using callbacks ❑ Working with advanced techniques to develop controls that support asynchronous behavior using client callbacks By far the easiest way to do this is to use the existing controls shipped with ASP.NET 2.0 that support this functionality, such as the GridView, DetailsView, and TreeView controls. No JavaScript or156 What Is Built into ASP.NETexplicit server-side coding is required to utilize asynchronous callbacks. Simply set some properties andlet the controls do the rest.For any custom behavior, the most common application will be implementing the ICallbackEventHandler interface and crafting it to meet your applications requirements. In the examples shown inthis chapter, you explored various ways to interact with the client-side code and server-side code, andin particular, examined ways of packaging custom data to transfer between the client and server side.Finally, you engaged in a brief examination of the ICallbackContainer interface that is used for moreadvanced scenarios in the creation of custom controls that support asynchronous client script callbackfunctionality.Asynchronous Client Script Callbacks provide a framework to utilize Ajax-like functionality that is inte-grated with the server-side-centric development nature of ASP.NET. It is a powerful framework that isflexible, but does require some manual effort to customize to meet your applications requirements.Experimentation is the key to becoming adept at making this powerful feature set work the way youwant it to.It is worth mentioning here that the future of asynchronous client script callbacks actually lies in a tech-nology that Microsoft is currently developing, code named Atlas. Atlas will make the implementationof asynchronous functionality on the client as well as the server significantly easier. It will consist of avastly enhanced client-side framework, as well as tightly integrated server controls to make what hasbeen demonstrated in this chapter achievable with far less effort and complexity.Atlas technology will be covered in detail later in this book starting at Chapter 10. 157 7 Ajax.NET Professional Librar yEvery once in a while, a technology is extremely simplified with the introduction of new wrapperlibraries. These libraries use existing technologies but make the development process easier to useby wrapping the sometimes difficult concepts into easier-to-use, more simplified concepts. So, theterm wrapper library comes from having a library of code wrapped around existing technology. Youcan tell when a great wrapper library is released because of its instant popularity.This chapter covers one such wrapper library known as the Ajax library for .NET. In this chapterand the next, we will show off the simplicity of talking back and forth between client browsers andyour application server without page postbacks. We’ll also dig a little under the hood of the libraryto show you how and why the library works.This chapter shows you how to get started using the Ajax.NET Pro library. To get started, you’ll setup a simple example and get it working. The following topics will be covered: ❑ Acquiring Ajax.NET Pro ❑ Adding a reference to the Ajax.NET Pro assembly ❑ Setting up the Web.Config to handle Ajax requests ❑ Registering the page class ❑ Writing methods in code-behind to be acces ...
Nội dung trích xuất từ tài liệu:
Beginning Ajax with ASP.NET- P13Chapter 6 The {1} placeholder represents the: “WebForm_InitCallback()” JavaScript code, which collects and prepares the form data to post to the server for the callback to the server to be correctly interpreted and trapped by the ASP.NET runtime engine. This is crucial so that the correct server-side methods are executed in response to the callback event as expected. Finally, the {2} placeholder represents the code: Page.ClientScript.GetCallbackEventReference( this, arg, “MyControl_Callback”, “null”)); This code should look familiar, and is the same method used to obtain a callback event reference in the initial page-centric examples detailed previously in the discussion of the ICallbackEventHandler interface. It is used for exactly the same purpose here, as the final step to initiate the asynchronous call- back request to the server. To summarize, the implementation of the ICallbackContainer method first constructs the arguments to send to the server-side callback request and returns a JavaScript block that first clears the posted data, initializes the collection of the posted data in the HTTP request (via WebForm_InitCallback() ), and finally initiates the callback request by obtaining the callback event through the Page.GetCallbackEventReference method. This section is not intended as a complete discussion on the specifics of implementing asynchronous callback functionality within your custom controls, but merely serves as an introduction on how to begin such a task with asynchronous callbacks in mind. The reader is encouraged to perform further investiga- tion in this advanced topic area and in particular in the creation of custom controls.Summar y This chapter has introduced the concept of Asynchronous Callback Client Scripts that are provided with ASP.NET 2.0. This feature allows a developer to utilize Ajax-like functionality within ASP.NET in a num- ber of ways. You looked at how you could include asynchronous callbacks in your applications by: ❑ Using “out-of-the-box” server controls that come included with ASP.NET ❑ Implementing the requisite interfaces to enable your pages to support asynchronous behavior using callbacks ❑ Working with advanced techniques to develop controls that support asynchronous behavior using client callbacks By far the easiest way to do this is to use the existing controls shipped with ASP.NET 2.0 that support this functionality, such as the GridView, DetailsView, and TreeView controls. No JavaScript or156 What Is Built into ASP.NETexplicit server-side coding is required to utilize asynchronous callbacks. Simply set some properties andlet the controls do the rest.For any custom behavior, the most common application will be implementing the ICallbackEventHandler interface and crafting it to meet your applications requirements. In the examples shown inthis chapter, you explored various ways to interact with the client-side code and server-side code, andin particular, examined ways of packaging custom data to transfer between the client and server side.Finally, you engaged in a brief examination of the ICallbackContainer interface that is used for moreadvanced scenarios in the creation of custom controls that support asynchronous client script callbackfunctionality.Asynchronous Client Script Callbacks provide a framework to utilize Ajax-like functionality that is inte-grated with the server-side-centric development nature of ASP.NET. It is a powerful framework that isflexible, but does require some manual effort to customize to meet your applications requirements.Experimentation is the key to becoming adept at making this powerful feature set work the way youwant it to.It is worth mentioning here that the future of asynchronous client script callbacks actually lies in a tech-nology that Microsoft is currently developing, code named Atlas. Atlas will make the implementationof asynchronous functionality on the client as well as the server significantly easier. It will consist of avastly enhanced client-side framework, as well as tightly integrated server controls to make what hasbeen demonstrated in this chapter achievable with far less effort and complexity.Atlas technology will be covered in detail later in this book starting at Chapter 10. 157 7 Ajax.NET Professional Librar yEvery once in a while, a technology is extremely simplified with the introduction of new wrapperlibraries. These libraries use existing technologies but make the development process easier to useby wrapping the sometimes difficult concepts into easier-to-use, more simplified concepts. So, theterm wrapper library comes from having a library of code wrapped around existing technology. Youcan tell when a great wrapper library is released because of its instant popularity.This chapter covers one such wrapper library known as the Ajax library for .NET. In this chapterand the next, we will show off the simplicity of talking back and forth between client browsers andyour application server without page postbacks. We’ll also dig a little under the hood of the libraryto show you how and why the library works.This chapter shows you how to get started using the Ajax.NET Pro library. To get started, you’ll setup a simple example and get it working. The following topics will be covered: ❑ Acquiring Ajax.NET Pro ❑ Adding a reference to the Ajax.NET Pro assembly ❑ Setting up the Web.Config to handle Ajax requests ❑ Registering the page class ❑ Writing methods in code-behind to be acces ...
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 318 0 0 -
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 276 0 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 266 0 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 207 0 0 -
101 trang 200 1 0
-
Giới thiệu môn học Ngôn ngữ lập trình C++
5 trang 195 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 167 0 0 -
Luận văn: Nghiên cứu kỹ thuật giấu tin trong ảnh Gif
33 trang 153 0 0 -
Luận văn tốt nghiệp Công nghệ thông tin: Xây dựng website bán hàng nông sản
67 trang 142 0 0 -
Giáo trình nhập môn lập trình - Phần 22
48 trang 138 0 0