1 IsPostBack Introduction
IsPostBack is the page class has a bool-type attribute to determine whether the request for the current form is the first or not the first request. When Ispostback=true represents a non-first request, we call it postback, when Ispostback=false represents the first request. There are many scenarios within the ASP.NET framework that need to be judged IsPostBack, such as loadallstate, which need to be done at postback time. When we use WebForm for our own development, we often judge the IsPostBack in Page_Load, because the Page_Load is executed on the first request and the Page_Load is executed when the request is not made on the first occasion. Why do you have multiple requests for the same form? The introduction of server-side events in ASP.net, the control that supports server-side events, makes a request to the current form, so that in many cases we need to distinguish whether it is the first request for this form.
2 IsPostBack Conclusion
I'm right. NET source code in the relevant processing of the analysis to get the following conclusions:
Conclusion ① the Ispostback=false of the page to which you migrate when using Server.Transfer.
Conclusion ②post method If request value is not requested, that is, Request.Form =null ispostback=false;get If request value is not requested, that is Request.QueryString = Null is Ispostback=false.
Conclusion ③ if QueryString or form has a request value, but the key in QueryString or form does not have "__viewstate" and "__eventtarget" and "__viewstatefieldcount", And no key is "null", the value starts with "__viewstate" and there is no key value pair with a value of "__eventtarget", then Ispostback=false.
Conclusion ④ use Response.Redirect mode to migrate from the picture at this time ispostback=false.
Conclusion ⑤ occurs on a cross-page commit (Crosspagepostback) when accessing the PreviousPage property for the source page,ispostback=true.
Conclusion ⑥ The target page is ispostback=false when a cross-page commit (Crosspagepostback) occurs
Conclusion ⑦ uses Server.Execute to migrate to the page its ispostback=false.
Conclusion ⑧ the corresponding DLL is updated during the page run and the page tree structure has changed, in which case the request is ispostback=false.
You can understand these conclusions in this way: Generally, it is ispostback=false if the request value is not available. 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 fields "__viewstate" to the client after each request). There are special situations where the rules are not properly judged and require special treatment. These situations include server.transfer,response.redirect,crosspagepostback,server.execute, changes in page elements, and recompilation.
Generally remember the above conclusion can be, if you are interested, or doubt please continue to see the following IsPostBack inference process.