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 only when the first open is false, all other times is true ! IsPostBack equivalent to Ispostback=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 property will be raised to determine whether the user has ever done a login or other event
6 if (! IsPostBack)
{
Response.Write ("First time submitted!");
}
if (IsPostBack)
{
Response.Write ("press button!");
}
2 IsPostBack Conclusion
Conclusion ① is the ispostback=false of the page migrated to when migrating with Server.Transfer.
Conclusion ②post method If request does not have the requested value, that is, Request.Form =null the Ispostback=false;get method if the request does not have the requested value, that is Request.QueryString = Null is Ispostback=false.
Conclusion ③ 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.
Conclusion ④ is ispostback=false when the Response.Redirect mode is used to migrate from the picture.
Conclusion ⑤ has a cross-page commit (Crosspagepostback), which is the source pageispostback=true when accessing the PreviousPage attribute. 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 ⑧ has its corresponding DLL updated during page run and the tree structure of the page has changed, in which case the request is ispostback=false.
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 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,
The page element was changed and recompiled.
Asp. NET in IsPostBack