In this paper, the usage of IsPostBack in asp.net is explained in detail, which will help readers to master the usage of IsPostBack in asp.net.
First, IsPostBack Introduction:
Page.IsPostBack is a flag: whether the current request is opened for the first time . The calling method is: Page.IsPostBack or IsPostBack or This.ispostback or this.Page.IsPostBack, they are all equivalent .
1 when opening a URL via IE's address bar, it is opened for the first time, and the page is no longer opened for the first time when it is submitted to the server by submitting a button or by submitting a button to post. (Every time you click the button, it is loaded one at a time)
2) IsPostBack is false at the first time and is true at all times.
3). NET to determine whether a page was first opened: request.form.count>0
4 Every time the page load, according to the need to load every time the code to put in the IsPostBack, only need to load the code once placed in the IF (! IsPostBack).
5 each time the user returned any information to the server, the IsPostBack attribute was raised to determine if the user had ever done a login or other event.
Ii. Conclusions on IsPostBack:
The analysis of the related processing in the. NET source code has the following conclusions:
1 The Ispostback=false of the page migrated to when using Server.Transfer for migration.
2 POST method If request value is not requested, that is, Request.Form =null is ispostback=false;get If request value is not requested, that is Request.QueryString = Null is Ispostback=false.
3 If the QueryString or form has a request value, but the key in the QueryString or form is not "__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.
4 use Response.Redirect mode to migrate from the picture, this time ispostback=false.
5) A cross-page commit (Crosspagepostback) occurs when accessing the PreviousPage property for the source pageispostback=true.
6 When a cross-page commit (Crosspagepostback) occurs, the target page is Ispostback=false
7 use Server.Execute to migrate to the page of its ispostback=false.
8 The corresponding DLL is updated during page run and the tree structure of the page has changed, in which case the request is ispostback=false.
Conclusion Summary:
General condition Ispostback=false If no value is requested in the request. If you have a request value but do not include some special keys or values such as "__viewstate", then Ispostback=false ( after each request. NET Framework will return some special hidden domain "__viewstate" to the client ). There are special situations where the rules above are not correctly judged and require special handling. These situations include server.transfer,response.redirect,crosspagepostback,server.execute, changes in page elements, and recompilation of .