asp.net AJAX Advance Tips & Tricks (5) UpdatePanel with jquery

Source: Internet
Author: User

Objective

Now more and more friends like to use jquery and ASP.net AJAX together, recently, many Indians in forum complained that UpdatePanel and jquery incompatible, many of the jquery effect after UpdatePanel Update does not work. This paper resolves this compatibility problem by analyzing the frame structure of both.

Problem Recurrence:

1. Add ScriptManager and UpdatePanel to the page

2. Add element A in UpdatePanel

3. Add x effect to element a with jquery

4. Add a buttonb as postback in the UpdatePanel

Result: When the first page load, the x effect of element A is normal, click B, page local refresh, at this time, element a loses x effect

Analysis 1:updatepanel

UpdatePanel is mainly used for local refresh in the application and avoids the postback of the whole page.

The core of UpdatePanel implementation of local refresh is Microsoftajaxwebform.js file, its local refresh process is to submit the page to the server (including ViewState), Executes the server-side code and asynchronously renders the HTML within the UpdatePanel.

During this process, the rest of the page does not have a status change.

Analysis 2:jquery

jquery can add a variety of properties and event handles to HTML elements with simple code, where we can see official documents:

Tutorials:How jQuery Works
http://docs.jquery.com/How_jQuery_Works

Here, we can see that jquery has an important event tag "ready", which is generally added to the effects of HTML elements and event handles, as follows:

$(document).ready(function () {
$("p").text("The DOM is now loaded and can be manipulated.");
});

The official explanation for this is that the ready event will run once after the DOM is fully loaded, OK, so the reason for the problem is almost clear:

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.