PostBack

Postback

Postback is the process when an ASP page is submitted to the server. It is done if some data is to be checked against database or when some data is to reloaded or refreshed after inserting or updating a record. It is a round trip from client side to the server and bacck to client.

Postback is originated from client side browser for example when user presses the save button. Then button will initiate the postback.

For example if save button is clicked

if (IsPostBack)
{
   InsertRecord();
}

IsPostback propert determines if page is posted back from server or it is loading for the first time.

If loading for the first time a gridview could be binded as following in the page load event.
if(!IsPostback)
{
   BindData();
}

During the postback ASP uses viewstate to maintain the state of controls on the form. It is a method which preserves the state of control between round trips. It is done on the page level and is turned on by default. It keeps the value of control without using a session.


AutoPostback



Controls which can not submit the form on their own are provided a property know as Autopostback.
For example if different data is to be shown on dropdownlist selected index change event, if it's Autopostback property is set to true it will fetch records based on its value, which will result in data shown. If control's Autopostback property is set to true .Net framwork inserts some code in HTML to implement this functionality.
For example
1  Java script method with name __doPostBack (eventtarget, eventargument)
2 Two Hidden variables with name __EVENTTARGET and __EVENTARGUMENT
3 OnChange JavaScript event to the control






For further question please mail: brainstormiert@gmail.com