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 you open a URL by using IE's address bar, it is the first time you open it, when you pass the page's submit button or the server that can cause the submitted button to post, The page is no longer open for the first time . (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=false The 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, for source 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 situation Ispostback=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