Pages

Friday, August 24, 2012

What is Post Back in ASP.Net?


PostBack, is a common method of sending data back to the web server as part of your request from a web client application (browser). For example, while you click on a button, the button control will initiate a PostBack event. Then, the state (data) of this button control and all other controls on the page will send back (posted back) to the web server through a GET or POST HTTP request. If the page is loading first time the PostBack event will not occur, meantime the value of IsPostBack property would be false. If the page is being loaded in response to a client postback, then the value of IsPostBack property would be true. While PostBack event triggers, the page control's properties will load from ViewState. 
User could verify that if the PostBack event will fire or not by validating the IsPostBack property on the page's Page_Load function. For example,



private void Page_Load()
{
    if (!IsPostBack)
    {
        // Validate initially to force asterisks
        // to appear before the first roundtrip.
        Validate();
    }
}



You could use "AutoPostBack" property to configure some web server controls PostBack events. The AutoPostBack property for a control is used to change whether that control’s default event causes an automatic PostBack to the server. 

For more details about Request and Response, click onWhat is a Request and Response?

No comments:

Post a Comment