Difference Between a Postback and a Callback in ASP.Net

"A postback is a request sent from a client to a server from the same page that the user is already working with."

ASP.NET was introduced with a mechanism to post an HTTP POST request back to the same page. It's basically posting a complete page back to the server (in other words sending all of its data) on the same page. So, the entire page is refreshed.
In order to understand how this postback mechanism works in ASP.NET, use the following simple procedure:

  • Add a new ASP.NET web form page to a project, for example WebForm1.aspx.
     
  • View the page code in HTML Source view. You will find something as in the following screen.

    HTML Source view
     
    Look for the form line of code as in the following:

    <formid="form1"runat="server">

    It represents a server-side implementation of the form control.
     
  • Now just run the application to see the WebForm1.aspx page and view its source code. The HTML source of the page will be displayed form an element as follows:
     

    <formmethod="post"action="WebForm1.aspx"id="form1">

You can see that an HTML form element is generated with an HTTP method as "POST" and action="WebForm1.aspx". So, if a submit button is clicked then the page will postback to itself by default.

"A callback is generally a call for execution of a function after another function has completed."

But if we try to differentiate it from a postback then we can say that it is a call made to the server to receive specific data instead of an entire page refresh like a postback. In ASP.NET, it's done using AJAX, that makes a call to the server and updates a part of the page with the specific data received.

Up Next
    Ebook Download
    View all
    Learn
    View all