Embracing Change-from Atlas to ASP. NET Ajax (3): "benevolent" updatepanel

Source: Internet
Author: User
Before reading this article, you must complete the installation Microsoft ASP. NET Ajax V1.0 Beta (For details, see Embrace change--SlaveAtlasToASP. NET Ajax(1): Download and install Overview ). After the installation is complete, Visual Studio Creating Web Site There will be an additional template: ASP. NET Ajax enabled web site . The subsequent content will be based on the newly created ASP. NET Ajax enabled web site .

InASP. NET Ajax, RelativeScriptmanagerEarth-shaking changes,UpdatepanelThe changes are much more friendly and easy to understand.UpdatepanelWill remain the most importantASP. NET AjaxThe server-side control exists inASP. NET AjaxCore Components (Microsoft ASP. NET Ajax V1.0 BetaTo make some part of the page have the asynchronous update function.

This article analyzesAtlas,ASP. NET AjaxMediumUpdatepanelControls.

 

Scriptmanager settings

AndAtlasSame,ScriptmanagerOfEnablepartialrenderingAttribute must also be setTrueBut this is alreadyASP. NET AjaxIn the default settings, we generally do not need to manually intervene. In addition,ASP. NET AjaxInScriptmanagerAnd exposedAsyncpostbackerrormessageProperties,AsyncpostbacktimeoutAttributes andAsyncpostbackerrorEvent, which can be usedUpdatepanelException thrown during asynchronous update. For details, seeEmbrace change--SlaveAtlasToASP. NET Ajax(2): The changes have changed dramatically.Scriptmanager(DflyingThere are still manyPlease advise).

 

Let's proceed from the DeclarationUpdatepanelThe labels start to show their changes one by one:

<Asp: updatepanel>Tag

Similarly, the original"ALTAS"Prefix changed to"ASP". Below isUpdatepanelThe following attributes are supported:

  1. Rendermode: Same as the originalAtlas scriptmanagerIdentical, indicatingUpdatepanelFinal PresentationHtmlElement.Block(Default)<Div>,InlineIndicates<Span>Select according to the layout requirements.
  2. updatemode : similar to the original Atlas scriptmanager , indicates the update mode of updatepanel . Optional always or conditional . always (default) indicates asynchronous or full-page delivery regardless of the type ), updatepanel . conditional indicates that only the current updatepanel > trigger , or childrenastriggers attribute is true current updatepanel , and whole-page delivery, or server-side call Update () method to update the updatepanel .
  3. Childrenastriggers: Boolean value (default value:True) New attribute, indicating that whenUpdatemodeThe property isConditional,UpdatepanelWhether asynchronous sending caused by the control contained inUpdatepanel. Note that whenUpdatemodeIsAlways,ChildrenastriggersCannot be setFalseOtherwise, the page will throw an exception.

 

Next let's take a look<Asp: updatepanel>The changes of each seed tag in the tag:

<Triggers> label

<Triggers>TheUpdatepanelSet of triggers. InAtlasOfUpdatepanelSupportedControlvaluetriggerAndControleventtriggerTwo triggers,ASP. NET AjaxOfUpdatepanelThen the two are unifiedAsyncpostbacktriggerIn addition, another trigger --Postbacktrigger. Details are as follows:

<Asp: asyncpostbacktrigger> label

AsyncpostbacktriggerIt is used to specify a server-side control and the server-side events that are triggered asUpdatepanelOfAsynchronousUpdate trigger, similarAtlasInControleventtrigger.AsyncpostbacktriggerThe following two attributes are supported:

    1. Controlid: Server-side controlID.
    2. Eventname: A server-side event of a server-side control.

<Asp: postbacktrigger> label

InAtlasOfUpdatepanelIn the left-side navigation pane.ASP. NET AjaxMediumPostbacktriggerTo make up for this defect, giving developers more flexibility.PostbacktriggerYou can point to the localUpdatepanelIn this way, the whole page delivery model will still be used for sending back caused by the control.PostbacktriggerThe following attributes are supported:

    1. Controlid:<Contenttemplate>TheID.

 

<Contenttemplate> tag

AndAtlasOfUpdatepanelIn<Contenttemplate>Identical, used to place local page content that requires asynchronous updates.

 

Asynchronous and full-page delivery

The so-called "Whole-page delivery" refers to the traditionalHTTP POSTThe page content will be completely refreshed after delivery. The so-called "asynchronous delivery" means that the delivery will passXMLHttpRequestWhen the object is asynchronously executed, the page content can still be retained.

By default,ASP. NETAll replies are full-page replies. HoweverUpdatepanelThen, the return of the control in the following circumstances will be changed to asynchronous:

    1. InUpdatepanelBesides<Asp: asyncpostbacktrigger>Reference, asUpdatepanelControl of the trigger for asynchronous updates.
    2. InUpdatepanelMedium,WeiThisUpdatepanelOf<Asp: postbacktrigger>The referenced server-side control.

RelativeAtlas,ASP. NET AjaxAsynchronous sending in also adds several client events, allowing the client to have similar server eventsWeb formThe concept of lifecycle. This is done by working with the clientPagerequestmanagerObject.

PagerequestmanagerObjects expose the following events and provide sufficient space for customization:

  1. Initializerequest: In the event processing function, we can perform some additional tasks before sending the request back to the server, for example, canceling an asynchronous request or modifying the parameter information of a server to be sent back. The parameter of this event isInitializerequesteventargs.
  2. Beginrequest: The event triggered when an asynchronous request is about to be sent. In the event processing function, we can display the updated information (UpdateprogressControls ). The parameter of this event isBeginrequesteventargs.
  3. Pageloding: Events triggered when an asynchronous request is ongoing. In the event processing function, we canUpdatepanelPrepare for the upcoming updates, such as releasing used resources. In the event processing function, we can also check the status information sent by the server and complete corresponding operation control based on different statuses. The parameter of this event isPageloadingeventargs.
  4. Pageloaded: The event triggered when an asynchronous request is returned. In the event processing function, we can access the event after the update is complete.UpdatepanelNew Content. The parameter of this event isPageloadedeventargs.
  5. Endrequest: Events triggered when an asynchronous request is completed. In the event processing function, we can display the exception information and hide information that may be encountered during the update.UpdateprogressControls, or other additional operations. The parameter of this event isEndrequesteventargs.

 

UpdatepanelUpdate policy

ASP. NET AjaxInUpdatepanelThe function is greatly enhanced, and its update policy is also more complex (Order is equally important! First, make sure that you understand the difference between asynchronous and full-page delivery in the previous section ):

  1. The whole-page delivery will update allUpdatepanel.
  2. CallUpdatepanelOfUpdate ()Method will update thisUpdatepanel.
  3. IfUpdatepanelOfUpdatemodeThe property isAlways, Then any asynchronous delivery will updateUpdatepanel.
  4. IfUpdatepanelOfUpdatemodeThe property isConditional, ThenUpdatepanelOfAsyncpostbacktriggerThe asynchronous sending will update thisUpdatepanel.
  5. IfUpdatepanelOfUpdatemodeThe property isConditional, AndChildrenastriggersThe property isTrue,UpdatepanelThe asynchronous delivery triggered by the surrounded control updatesUpdatepanel.

 

Tips

ASP. NET AjaxInUpdatepanelIn essenceAtlasInUpdatepanelThere is no difference, so it appliesAtlasMediumUpdatepanelSome of the usage tips will still apply. Please refer:

    1. Atlas updatepanelBrief Introduction
    2. Atlas updatepanelTips and FAQs

 

Postscript

RelativeScriptmanager,UpdatepanelThe changes seem "benevolent". With the help of comprehensive official documentation, I am basically familiar with the newUpdatepanel. However, the time was just as hasty, and the text was still sloppy. There was still not much polishing, and there was no step-by-step example.Program...... Naturally, there will be a lot of difficult to understand-but this article is not a basic entry pointArticle, As a slaveAtlasRedirectionASP. NET AjaxReaders, you should be able to understand the meaning of the text and quicklyUpdatepanelGet familiar with it.

Here are some of the mistakes. Please give me some comments or share your thoughts! Thanks again for your support!

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.