Ajax NOTE 2: updatepanel

Source: Internet
Author: User
Updatepanel is the most important Ajax control. It is a container and a unit for partial refreshing.

First, let's look at its refresh mode.
In my previous note, I used the updatepanel "active" method to specify the trigger. In addition, I can also choose not to set the trigger on the updatepanel side, and "passively" Accept the refresh.

In general, there are three ways to update it:
<1>. it is automatically updated because it is returned by the updatepanel sub-control. this mode is the default action. For example, put a button in updatepanel to write code for the button click event. In this way, when you click this button, updatepanel returns and updates its content. however, if the button click event changes content other than updatepanel, the update will not be immediately displayed, because the whole page is not updated and the previous note of this experiment has already been described.

<2> updatepanel specifies a control that is not a sub-control. The trigger does not know whether it will cause the whole page to be returned or the updatepanel to be returned locally. this is the method used in the previous article. set the triggers attribute of updatepanel, and the external button should have caused the whole page to be returned. However, after the updatepanel Declaration, this button becomes the exclusive updatepanel, this button does not need to be approved.

<3> updatepanel does not know when it will be updated. It depends entirely on other controls. in this case, you must set its updatemode to conditional, so that any function can call its update method to re-paint it, regardless of whether the Sub-control is irrelevant.

With the above discussion, it is easy to understand the several key attributes of updatepanel. If you want to update them using the second and third methods, you must set the updatemode attribute to conditional, the first method must be set to always. If you want the sub-control to trigger the event, set childerastriggers to true; otherwise, set it to false.

Updatepanel can be nested with each other, but this nesting is only the appearance of nesting, ----- when the inner updatepanel is updated, it does not cause the outer updatepanel re-painting.

Then let's look at the updatepanel layout.

Updatepanel does not have attributes such as height and width, so it cannot be set. However, after being dragged from the toolbox, it will have a default size. If you move it to two widgets, these two controls will be stacked one by one instead of a row. if you want to arrange the child controls in a row, you need to write a DIV in the updatepanel code page and put all the content into this Div, then, if the DIV width is set to be greater than or equal to the horizontal width of all controls, these controls are automatically arranged in a row.

Related Article

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.