Difference between a Postback and a Callback in ASP.NET






4.33/5 (8 votes)
Difference between a postback and a callback in ASP.NET
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 server (i.e. sending all of its data) on the same page. So, the whole page is refreshed.
In order to understand how this postback mechanism works in ASP.NET, follow the simple steps:
- Now just run the application to see WebForm1.aspx page and view its source code. HTML source of the page will display
form
element as follows:<form method="post" action="WebForm1.aspx" id="form1">
You can see that an HTML
form
element generated with an HTTP method as "POST
" andaction="WebForm1.aspx"
. So, if a submit button is clicked, 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: It's a call made to the server to receive specific data instead of whole page refresh like a postback. In ASP.NET, it's achieved using AJAX, that makes a call to server and updating a part of the page with specific data received.
Related Web Development Tutorials
- Top 10 HTML5 Interview Questions
- 7 jQuery code snippets every web developer must have
- WCF Vs ASMX Web Services
- 3 simple steps to create your first ASP.NET Web API service
- Difference between ASP.NET WebForms and ASP.NET MVC