Asp. NET of IsPostBack

Source: Internet
Author: User

Learn ASP. IsPostBack attribute, as the name implies, this is whether the meaning of postback, more used to judge is not the first time to open

I. Introduction of IsPostBack

Page.IsPostBack is a flag: whether the current request is opened for the first time. The call methods are: Page.IsPostBack or IsPostBack or This.ispostback or This.Page.IsPostBack, both of which are equivalent.

1) when opening a URL via IE's address bar, the first time it is opened, the page will no longer be opened for the first time when it is submitted via the page's submit button or the server that can cause the submitted button to post. (Each time the button is clicked, it is loaded once)

2) IsPostBack is true only if the first time it is opened is false.

3). NET determines whether a page is opened for the first time: request.form.count>0

4) Each time the page load, according to the need to load each time the code is placed in the IsPostBack, only need to load the code once placed in the IF (! IsPostBack).

5) Each time the user callbacks any information on the server, the IsPostBack attribute is raised to determine if the user has ever done a login or other event.

Ii. conclusion of IsPostBack

The analysis of the related processing in the source code of. NET results in the following conclusions:

1) The Ispostback=false of the page migrated to when Server.Transfer is used for migration.

2) Post method if the request does not have the requested value, that is, Request.Form =null Ispostback=false;get method if the request does not have the requested value, that is, request.querystring = Null is Ispostback=false.

3) If the QueryString or form has a request value, but the key in QueryString or form does not have "__viewstate" and "__eventtarget" and "__viewstatefieldcount", And there is no key of "null", the value begins with "__viewstate" and there is no key value pair that has a value of "__eventtarget", then Ispostback=false.

4) When migrating from the screen using Response.Redirect mode, this is Ispostback=false.

5) A cross-page commit (Crosspagepostback) occurs when the PreviousPage attribute is accessed for the source pageispostback=true.

6) When a cross-page commit (Crosspagepostback) occurs, the target page is Ispostback=false

7) Use Server.Execute to migrate the page to its ispostback=false.

8) The corresponding DLL has been updated during page run and the tree structure of the page has changed, in which case the request is ispostback=false.

In short, it is possible to understand these conclusions: the general case is that if no request value is ispostback=false. If you have a request value but do not include some special keys or values such as "__viewstate", then Ispostback=false (the. NET Framework will return some special hidden domain "__viewstate" to the client after each request). There are special cases where the above rules are not correctly judged and need special treatment, These scenarios include Server.transfer,response.redirect,crosspagepostback,server.execute, where page element changes and recompilation occur.

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.