ASP.NET – Post back handling


Some scenario, the information of the web pages submitted to the server for further process and server respond accordingly and serves less or more dynamic information back to the web pages as its request. That means, the client requests are send to the server, server responses send back to the client in single cycle. This cycle is called postback. The events initiate these phenomenon are called postback events.

PostBack within the page:

Web pages posted with initial information when required by certain events to render again with posted information, using information to fire method or function to get the result and display back with dynamic content. This phenomenon is called post back.

  1. For example selection of country in the country list box needs to load the corresponding states of country in the states list box control dynamically. So we need to instruct the system when user select the country, page need to post back once. server controls achieve this using ‘AutoPostBack’ property set to ‘True’.
  2. When user opens the page first time there was no default country code selection. So that the initial content need not populated with ‘states’. That means function to populate ‘states’ only need to fire after selection made on the country box. ‘Page.IsPostBack’ function using to check whether the page is post or postback.

protectedvoid Page_Load(object sender, EventArgs e)


if (Page.IsPostBack == true)


Response.Write(“Populate states control.”);




string[] values = { “-Selected-“,“Singapore”, “Malaysia”, “Indonesia”, “China”, “Hang hong” };

this.DropDownList1.DataSource = values;




Cross page postback:

Extended functionality of postback the information, from one page to another page is called cross-page postback. For example : Search employee’s payslip or time sheet populated in the search page need to displayed with detailed information in printable format when request print preview.


//Part of the first page code (First.aspx)



<asp:LabelID=”lblCrossPageInformation”runat=”server”Text=”This information from First.aspx”></asp:Label>




//Part of the Second page (Second.aspx) Page_load

protectedvoid Page_Load(object sender, EventArgs e)


if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)


Label lbl = (Label)Page.PreviousPage.FindControl(lblCrossPageInformation);

if (lbl != null)







Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s