Use ispostback to check whether the webpage is accessed for the first time (Asp.net)

Source: Internet
Author: User
When we want to execute another Code(Basically, it is the default data binding), and even want some code to be executed at each loading except the first loading. We can use the ispostback feature to complete this function. When a webpage is loaded for the first time, the value of this attribute is false. If the webpage is reloaded due to sending back, the value of the ispostback attribute is set to true.

Application in ASP. NETProgramIf you want to perform initialization operations when the page is displayed for the first time, you must determine the ispostback attribute!

In ASP. net use page. ispostback, you can avoid extra work on the round-trip: If you process the Server Control to send back, you usually need to execute the code on the first request page, this code is different from the code used for round-trip when an event is triggered. If check? Page. ispostback? The code can be executed according to the conditions, depending on whether there is an initial request to the page or a response to the server control event. This seems obvious, but you can ignore this check without changing the page behavior. The usage of this attribute is directly related to whether your program runs as expected, and the efficiency of the entire page. Because, if you bind data to the control every time, no matter whether you access the control for the first time or submit the data, the efficiency of the page program can be imagined.

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.