Ajax platform policies for. NET developers

Source: Internet
Author: User

Here I will try to check the current. the Ajax framework under the NET platform, I also try to sum up a method from it, so that you can. the Ajax framework and toolkit of the. NET platform find one of your most suitable ones. At the same time, we hope that you will evaluate, pre-develop, and use these popular Ajax-NET frameworks, be rational and targeted.

I think the methods in this article will help. NET users who currently use Ajax, so as to improve your Ajax experience on the. NET platform. Why? Recently, the R & D director of one of my clients (probably some customers) told me that we are very interested in Atlas, I would like to know more about Atlas and how to get started with it, as an Atlas expert will talk to us next month. Because I know that this supervisor has mastered the business application of an Ajax architecture, which is currently under consideration.. NET v1.1. to what extent can Atlas help him or his Team? I didn't say much, because I was a little surprised. Currently, their Architecture Application Atlas may not be a wise choice. Of course, this worry is based on my current understanding of Atlas.

The Ajax-NET frameworks and tools I have listed and discussed include Atlas (Jan CTP) and Anthem. NET, MagicAjax. NET, Ajax. NET Professional and wwHoverPanel Control, which is basically my concern.. NET platform. Basically, it is also listed in my article. Another reason is that they are basically open-source, which is very important. Because there is no source code, we will not know what happened. In addition, I have no intention of making it a comparison report by Daniel Zeiss.

First, let me explain my point of view.

The selection of open-source or existing Ajax-NET technology or framework must be based on your current application architecture. If your current architecture is "Ajax, therefore, you must be very careful when choosing all popular Ajax-NET technologies. However, if your current applications use traditional ASP.. NET application architecture (or prepare to use ASP. NET v2.0 starts to create new applications), so the popular Ajax-NET frameworks and technologies are generally suitable. The key is to select a suitable framework or implementation at the right time.

In my eyes, the popular Ajax-NET frameworks or implementations are all in the Add-in (Plug-in) mode, that is to say, these frameworks use traditional ASP for all the latter.. NET application architecture (or prepare to use ASP. NET v2.0 starts to create new applications) is Awared, which is very advantageous and convenient. However, for Ajax-like architectures, the situation is different. You need to measure the situation from another perspective and choose to use it.

What is the "Ajax-like" architecture? That is to say, your application was created before the Ajax concept was proposed. From the perspective of Interaction Analysis between the client and the server, your client has a large amount of Javascript code to accept XML data, serialize objects, and then use Javascript with other HTML technologies to present these objects and data, you may also have a bunch of HTML presentation layer controls for HTC or other Javascript. Your server is a Handler controller in the Facade (or Adapter, Observer) mode. After receiving XML request data from the client Javascript, parse the XML, then, call a service or service component and return the result to the client Javascript in XML format. After receiving the client Javascript, process and display the result, because html dom and CSS can be used, the display of all pages is dynamic.

In this way, the client uses the Script-centric architecture or Data-centric interactions method described in. In addition, this method is the most similar to the Ajax method listed by Jesse James Garret, But you or I didn't know it could be called Ajax at that time, but now people misunderstand Ajax, ajax has become a technology and a feature, instead of a Web application under a certain architecture.

In addition, the popular Ajax-NET Framework basically does not implement bidirectional serialization, because the client only needs to receive data to implement automatic completion of a TextBox, there is no need to return data or objects to the server at all, and there is no need to make an Ajax status progress bar, but these are all Ajax. The standard we measure is asynchronous and the page is not refreshed.

Sorry, I used this word to explain my point of view. Finally, if your application is already in the Ajax architecture, You need to carefully choose to use the current Ajax-NET framework to ensure that it also provides the bidirectional serialization function, compatible with your original application and architecture. If your application is not based on the Ajax architecture, you can select the Ajax-NET Framework Based on some conditions.

Then let's go back to the beginning of the article and look at some popular Ajax-NET frameworks.

1. MagicAjax. NET

This is an Ajax-NET implementation with the smallest version number in the current framework. Many people like it very much or even like it. But after reading its code, I am somewhat worried.

MagicAjax. NET is based on such a policy, that is, _ doPostBack will mention the entire ASP. NET page, this will cause the page to be refreshed, so MagicAjax. NET using AJAXCbo. doPostCallBack is used for local submission, and the content in each AjaxPanel corresponds to the real-time HTML content of the client, because the content in MagicAjax. NET, the client only needs to execute the HTML returned by the eval (responseText) server Rendered (very passive ).

Because DoPostCallBack submits ViewState and AjaxPanelx $ RBS_Store, it uses XMLHttpRequest to simulate a normal submission. Therefore, the server can create page instances or restore the status of all controls based on ViewState, similarly, both AjaxPanel and AjaxControl will be instantiated, and then the _ EventTarget and _ EventArgument sent from the client will follow the normal ASP. NET control processing process, after the control Rendered, the final HTML output is sent back to the client, and then displayed by the client eval.

The entire process is very clever. This is almost the "Hook ASP. NET" and enhanced version of ASP. NET _ doPostBack. HttpModel is mainly used to organize and inject client Javascript to solve Session and cross-commit. Of course, it also receives client requests and returns results in Application_EndRequest. The rest of the code is supported by the control in the Design of VS Web Design. AjaxCallObject. js and WebParts. js are uploaded to the client every time.

MagicAjax. NET's shortcomings and ideas:

  • 1. enhanced version of _ doPostBack, suitable for advanced ASP. NET users
  • 2. Because the page processing mechanism of ASP. NET is very closely dependent, the default action of the control may not work, such as a third-party custom control;
  • 3. ViewState is dependent. If ViewState is encrypted, it may not work properly. I did not try it. It seems that the _ VIEWSTATEENCRYPTED object is not seen in the code.
  • 4. optimized the submission of all ASP. NET pages to implement limited Ajax functions with little scalability

If it is based on the control and development provided by ASP. NET, MagicAjax. NET is very effective and can effectively solve the Session and cross-page status issues. In addition, client operations and work can be ignored. MagicAjax. NET is designed to be close to the nearest ASP. NET version. Currently, it does not provide a method to call the client directly to call the page. However, with its development, the advantage may be less and less, because the latest version of Atlas provides similar UpdatePanel controls.

I have never seen Ajax. NET Professional source code, but from the example it can be seen that it supports calling a method of the page, as well as the returned object, DataSet, DataTable data, I think Ajax. NET Professional implementation and Anthem. the NET principle is the same, although Ajax. NET Professional uses the HTTP Model.. NET. In comparison, Ajax. NET Professional does not inherit all common ASP.. NET Control implements partial submission, so Ajax. NET Professional is strong in calling a method on the page and obtaining the result data on the client. This is enough to implement most of the Ajax functions.

From this perspective, I think Ajax. NET Professional is relatively cumbersome and complex. Anthem. NET does not use the HTTP Model. It provides partial submission of controls and client method calls at the data level. The source code of Ajax. NET Professional always seems to be not shared, which is another reason I don't like it.

In any case, no two data exchanges are provided, that is, the client can obtain the server method and obtain results and data, however, these objects and data can be modified and then returned to the server.

Some shortcomings and ideas about Anthem. NET:

  • 1) Anthem. NET is also a "Hook ASP. NET, designed to make up for ASP. and PostBack on the entire page of. NET, and the client's data access and interaction are enhanced.
  • 2) Anthem. NET needs to re-inherit and package the controls provided by ASP. NET, so the usage and feature compatibility are very sensitive.
  • 3) Maybe the standard control of ASP. NET in the next version of Microsoft can use the practice of Anthem. NET to add the remote callback interface to each control.
  • 4) The current version has very powerful and slightly complex functions, and is easy to deploy. You do not need to set an HTTP Model.

2. Anthem. NET

The current version is version 1.0. Its design philosophy is to follow this idea through another idea-since ASP. NET standard controls do not implement the submission function, so I can generate a submission interface, and then inherit the original standard controls, and then implement this interface, in this way, each control can be submitted separately to the server.

The process of each control is similar to that of MagicAjax. NET, Anthem. NET provides the Javascript-side commit function for each control-this also intercepts _ doPostBack, and then. NET also provides complete client events such as PostCallBack and PreCallBack, and then uses XMLHttpRequest to simulate a traditional page to submit requests to the server, and the server generates page instances, this process and MagicAjax. NET. Finally, the Rendered HTML is passed back to the client in the control's Render () event. The innerHTML of the client control is assigned a value and updated dynamically.

And MagicAjax.. NET is different. NET does not have the concept of container, because each control has added the submit interface, so you can submit it separately, so the unit is to submit once in the unit of a control. NET (but the server side is similar, because the whole ASP.. NET page ).

In addition. NET also has another function, that is, you can call methods on the page through the client and obtain the results/data. In this case, you will call the Anthem_InvokePageMethod method instead of the Anthem.. NET provides the default submission method for each control. In this way, the result in the Javascript callback processing function. value will be able to obtain a method of the called server (This method uses [Anthem. method] indicates the execution result. Because there is Page/MasterPage/Control in the JavascriptPost data, the server can easily obtain the address of the Method through this identifier, and the application reflection will look for [Anthem. method], and then call it to return the result to the client.

Anthem. NET supports the returned objects, DataSet, able, and WriteDataRow (WriteDataSet, WriteDataTable, WriteDataRow, WriteObject). The returned strings conform to the JSON specification, so that the client Javascript can use these objects. Unlike MagicAjax. NET, Anthem. NET does not use HTTP Model, so the result is the result of processing and returning the request in the PreRender () event of the page.

Currently, in the wwHoverPanel scenario, I think this is a lightweight implementation. Under the pressure of multi-layer nested multi-group referenced object graph types or large-scale capacity access, both the client and the server need to be optimized. Therefore, if it is used as an Ajax architecture, the client and the server need to communicate with and transmit data on the communication layer.

WwHoverPanel's shortcomings and ideas:

  • 1) this control is the only Ajax control on the. NET platform that supports both client return and PAGE method calls, and supports two-way bidirectional serialization.
  • 2) Relatively speaking, wwHoverPanel is the simplest design. It is based on controls that do not depend on HTTP Model and ASP. NET Page Pipeline, and does not depend on ViewState.
  • 3) This control balances the technical aspects of Ajax feature implementation in customer return and client call page methods.
  • 4) Currently, the client callback supports the callback of other pages, but the output result must output the original HTML, which affects the application hierarchy and design.
  • 5) JSON bidirectional serialization is a good solution, but in high-performance scenarios, we should consider implementing a more efficient serialization framework.

3. wwHoverPanel AJAX Control for ASP. NET

WwHoverPanel AJAX Control for ASP. NET is also an ASP. NET Control, but it provides client callback (Advanced callback), client call PAGE method, and two-way serialization.

WwHoverPanel draws on the advantages of MagicAjax. NET and Anthem. NET, and integrates the client callback function of ASP. NET. It is a lightweight Ajax component.

One of the two biggest features of wwHoverPanel is to implement a HoverPanel Behavior in a simple way, which is simpler than the Behavior of Atalas, the author Rick Strahl also stressed that this is mainly based on his specific application. For example, here a small HTML board is provided to display the obtained result information.

WwHoverPanel also provides a local callback method, but this implementation is consistent with that of MagicAjax. NET and Anthem. NET is completely different. It uses a StartCallback Javascript to compose a query string and uses XMLHTTP to send a request to a server page (specified by the ServerUrl attribute ), then, the result is returned as Response. the native HTML content of Write () is returned. And ASP. NET callback method is very similar, and also supports sending requests to ASP. NET and obtain results, so it enhances the original ASP.. NET client callback method, that is, supports callback for other pages. It can be said that this is a URL-based client callback.

The second feature provided by wwHoverPanel is that the client can call the methods of a page on the server (these methods are identified by [CallbackMethod]). In this case, you need to set EventHandlerMode = "CallPageMethod", and then use wwHoverPanel. server method name (parameter, parameter ,..., callback handler. This actually uses a Javascript CallMethod method to call server-side requests. The HandleCallback of Javascript is used to process the returned results. The logic is relatively simple. Although the innerHTML of the control is also assigned a value, it is mainly used to maintain the small HTML board content displayed as the client callback result, otherwise, the method on the page is called, and the result is directly sent to the callback method of the client.

Feature 3: I am talking about the dual-path serialization function. In fact, we also need this scenario. For example, if we use the client callback or XMLHTTP request to obtain an order object, after the client modifies it, I also want to use it as an input parameter called by a client and return it to the server. At this time, two-way bidirectional serialization is required, because this time the server needs to serialize the data transmitted by Javascript Functions to. NET classes. This is the two-way serialization of JSON (the main code is in JSONSerializer. cs), which is also a feature I like very much, because I have been paying attention to this feature for a long time, but currently the popular Ajax-NET Framework does not support this feature.

4. Atlas

I will not list the specific functions of this product, but mainly talk about my views and attitudes towards it. Because I mentioned the problem in my Ajax book reviews.

Atlas is a distinctive product with obvious advantages and disadvantages, but you must first realize that it is still a complicated solution with a high learning curve. For its complexity, to be honest, most people still lack real feelings.

In recent versions of Jan CTP, we have seen some features, which are powerful in the following aspects:

  • 1. Client (Javascript) Data Binding and validation bring convenience.
  • 2. The new Update Panels not only features MagicAjax. NET, but also features better. It is currently the main control of asynchronous callback in Atlas.
  • 3. built-in controls with specific Ajax features, such as AutoCompleteExtender and DragOverlayExtender
  • 4. provides some used controls such as ScriptManager, Triggers, and TimerControl.
  • 5. The main purpose is to provide a client control and Server Control Feature integration solution and easy-to-use development efficiency.

However, the disadvantages are obvious, such:

  • 1. Behaviors of the client is still weak. The template and UI enhancement functions are not yet seen.
  • 2. the so-called Client Atlas Controls ("Atlas" Client Controls) and the Server-side Atlas Controls ("Atlas" Server Controls) do not yet have a clear specification, so now you basically cannot create custom Atlas controls (either on the client or on the server ).
  • 3. Currently, only the Web Services Service can be called. The built-in Services of ASP. NET and the service support of WCF are not visible, and the method calls in pages or controls are not supported.
  • 4. features are not stable yet. Some features are only implemented under specific conditions and cannot meet the requirements for deploying the production environment. In my opinion, if Atlas Releases Go-Live License, you can consider putting Atlas into a formal project or application.

I don't recommend that you apply it to an old ASP.. NET project, or the old project is migrated to ASP. NET v2.0 takes precedence over it. More often, if you create a new ASP. NET application, but beyond its learning curve, you can consider using it. In the current situation, for Atlas, I suggest that you keep enough attention and practice learning, but you should restrain your interest in applying it to projects. Because Ajax, you can start to pay attention to and learn about it now, but you may not select Atlas immediately because you want to implement Ajax.

(

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.