ASP.NET-012: Avoid flicker problems caused by page refresh

Source: Internet
Author: User

This article goes on to say a common sense question.
As we all know, ASP. NET page has a Page_Load event. This event is executed when the page loads for the first time. The careful children's shoes must also find that when the event is registered to the control on the page, the Page_Load is executed when the event is executed. This means that each click will refresh the page, causing the page to blink. This effect is not good.
So how to avoid this problem, of course, is by JavaScript, as well as the high-level jquery and so on.
The General ASP. NET page must be implemented with JavaScript. The events of the page control are best implemented in JavaScript, and then the data is passed through JavaScript, as well as on how to pass in Jquery.js and Ajax. Also mentioned in the previous two methods $.ajax and $.post two methods to achieve the front and back table interaction.
Another small detail is the use of the return keyword in the event of a control. as follows, a button's Click event can be defined like this.
<asp:button id= "button1" runat= "Server" text= "page click" onclientclick= "return Buttonclientclick ();"/>

The corresponding JS function:
       function Buttonclientclick () {          //Business          //Is $.ajax or $.post, and other methods and background interaction          return false;      }
The point is to add return when calling the function, and then remember to return to false in the function;
In this way, even through the JS method of interactive data, into the Page_Load method. The page will not blink.
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: 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.