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 through IE's address bar, etc., is the first time it is opened, when passed causes the submitted button to post the server, the page is no longer the first time you open the 2) IsPostBack only when the first opening is false, the other time is true
3). NET determines whether a page is opened for the first time: Request.form.count>0
4) Each time the page loads, the code to be loaded every time, as needed, is placed in IsPostBack, just The code loaded once is placed in the IF (! IsPostBack).
5) The IsPostBack property is raised every time a user callbacks any information from the server to determine that the 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.