What is IsPostBack Test in ASP.Net

What is IsPostBack Test in ASP.Net

What is IsPostBack Test in ASP.Net?

We can test whether a page is loaded for the 1st time or loaded as a result of post back by using the IsPostBack property of the page.

This property returns a value true if a page is loaded as a result of post back.

Thanks & Regards
Paritosh Mohapatra


Author: Shashwath7712 Aug 2010 Member Level: Gold   Points : 0

hi what happens with this


thanks in advance

Author: koti Balaji25 Jul 2013 Member Level: Silver   Points : 3

For Easy Understanding

asp:Label ID="Label1" runat="server" Text="Label"

asp:Button ID="Button1" runat="server" Text="Button"


protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
Label1.Text = "execution only at 1st time of load";

if (Page.IsPostBack)
Label1.Text = "execution due to post back of button";


Author: ketan Italiya26 Aug 2013 Member Level: Gold   Points : 4

PostBack is the name given to the process of submitting an ASP.NET page to the server for processing . PostBack is done if certain credentials of the page are to be checked against a database (such as verification of username and password). This is something that a client machine is not able to accomplish and thus these details have to be ‘posted back' to the server.

A simple example to illustrate the usage of PostBack is a login page. After the user has typed his username and password, he clicks on the ‘Login' button. Upon the click, the page is sent to the server to check against the database/XML file to check if the user with supplied details is an authenticated user.

Then there arise certain events ( Listbox Index Changed,RadioButton Checked etc..) in an ASP.NET page upon which a PostBack might be needed. Consider the case in which you have 2 ComboBoxes. Let us say the first ComboBox asks you for the Country you reside in and the second one asks you for the State/Province in that country. Based upon the Country you select, the list of States/Provinces must be shown. Thus, in order to fill the values in the second ComboBox, the selection in the first ComboBox must be known to the server. Thus, as and when an item is selected in the first ComboBox, a PostBack must be done and the appropriate list of items must be filled in the second ComboBox.

To handle these situations, you need to enable the ‘Auto PostBack' property for those controls whose events are going to trigger some kind of server processing (the case of the first ComboBox in the previous example).

Usage of IsPostBack in ASP.NWT-

IsPostBack is a Boolean property of a page when is set (=true) when a page is first loaded. Thus, the first time that the page loads the IsPostBack flag is false and for subsequent PostBacks, it is true. An important point to be noted here is that each time a PostBack occurs, the entire page including the Page_Load is ‘posted back‘ and executed.

Thus a very common programming practice is that whenever some part of the code is to be executed just the first time a page loads, it is checked against the IsPostBack flag.

If you have not understood the concept clearly, do not worry. Programming examples in subsequent posts will help making this concept clear.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: