“A postback is a request sent from a client to server from the same page, 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 server (i.e. sending all of its data) on same page. So, the whole page is refreshed.In order to understand how this postback mechanism works in ASP.NET, follow the simple steps:
- Look the form line of code.
<form id=”form1″ runat=”server”>
It represents a server-side implementation of form control.
- View the page code in HTML Source view. You will find something like following screen.
- Add a new ASP.NET web form page to a project e.g. WebForm1.aspx.
- 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” and action=”WebForm1.aspx”. So, if a submit button is clicked, the page will postback to itself by default.Following figure will also give you more understanding on ASP.NET Postback.More on IsPostBack property here.
- Series of ASP.NET Interview Questions and Answers
- A Complete Shopping Cart Application using ASP.NET MVC, C#, Entity Framework and SQL Server
- Build a Full-Stack Web Application with ASP.NET Core, Entity Framework Core and Angular 2 (Angular 4+)
“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, its achieved using AJAX, that makes a call to server and updating a part of the page with specific data received.
ASP.NET Core (ASP.NET 5) | MVC 6 | C# | Web API & EF Crash Course
Learn How To Build cross Platform Web Apps in ASP.NET Core (ASP.NET 5), Utilizing MVC 6, C#, Web Api & Entity Framework. Click Here to visit resource page for further details.
Other Related Articles:
- MVC 3 Vs MVC 4 Vs MVC 5
- Understanding Model First Approach in ASP.NET MVC5
- 7 jQuery code snippets every web developer must have
- 3 ways to generate proxy in WCF
- 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
- WCF Self Hosting in a Console Application
- ViewBag Vs ViewData Vs TempData in ASP.NET MVC
Top Web Developers Interview Questions and Answers Series:
- Top 10 HTML5 Interview Questions
- Top 10 ASP.NET Interview Questions
- Comprehensive Series of ASP.NET Interview Questions
- Top 10 ASP.NET MVC Interview Questions
- Top 10 ASP.NET Web API Interview Questions
- Top 10 ASP.NET AJAX Interview Questions
- Top 10 WCF Interview Questions
- Comprehensive Series of WCF Interview Questions