Asp. NET in IsPostBack detailed

Source: Internet
Author: User

1, IsPostBack Introduction
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 the server any information, the IsPostBack property will be raised to determine if this user is

Have you ever done any landing or other events?
6 if (! IsPostBack)
{
Response.Write ("First time submitted!");
}
if (IsPostBack)
{
Response.Write ("press button!");
}
2 IsPostBack Conclusion
I'm right. NET source code in the relevant processing of the analysis obtained the following conclusions:
Conclusion ① is the ispostback=false of the page migrated to when migrating with Server.Transfer.
Conclusion ②post method if the request does not have the requested value, that is, Request.Form =null ispostback=falseThe Get method is ispostback=false if the request does not have the requested value, that is, Request.QueryString =null.
Conclusion ③ if the QueryString or form has a request value, but the key in the QueryString or form does not"__viewstate" and "__eventtarget" and "__viewstatefieldcount", and there are no keysis "null", the value begins with "__viewstate" and there is no key-value pair with the value "__eventtarget", thenIspostback=false.
Conclusion ④ is ispostback=false when the Response.Redirect mode is used to migrate from the picture.
Conclusion ⑤ a cross-page commit (Crosspagepostback), when accessing the PreviousPage attribute, forSOURCE Pageispostback=true. Conclusion ⑥ when a cross-page commit (Crosspagepostback) occurs, the target page is Ispostback=false
Conclusion ⑦ uses Server.Execute to migrate to a page whose ispostback=false.
Conclusion ⑧ the corresponding DLL is updated during page run and the tree structure of page has changed, this situationIspostback=false at the time of request.
It is possible to understand these conclusions: the general situation is that if there is no requested value in the request 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 have some special hidden fields after each request )

"__viewstate", etc. returned to the client). There are special cases where the above rules are not correctly judged and require special treatment, including Server.Transfer, Response.redirect,crosspagepostback,server.execute, Fat
The page element was changed and recompiled.

Asp. NET in IsPostBack detailed

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.