I have this program in asp.net
<body>
<form id="form1" runat="server">
<div>
<asp:Button runat ="server" ID="btnTest" Text ="Request Somethig"
OnClick ="OnClick" />
</div>
</form>
</body>
And the code behind:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
Response.Write("A Post Back has been sent from server");
}
protected void OnClick(object sender, EventArgs e)
{
//The button has AutoPostBack by default
}
}
If I request the page to the server http://localhost:50078/Default.aspx ,the server will create an instance of the class _Default.cs, then it will fires and event Page_Load, and this line won't be executed the first time:
Response.Write("A Post Back has been sent from server");
And the reason is that IsPostBack=false
Then if I hit click on the button, I will request a post back from server, so now IsPostBack will be true and in my browser I will see the message
"A Post Back has been sent from server"
My question is: How the property IsPostBack is changed from false to true, and where is storage that value?
As far as I know, the instance that the server creates from the class _Default.cs is destroyed once the HTML is sent to the client,so, it suppose to have nothing about IsPostBack property when I click the button(doing a post back).
Does the server storage the value of IsPostback in a _VIEWSTATE hidden variable in the page itself?
Thanks in advance!!