Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a postback?

Tags:

postback

People also ask

What IsPostBack explain with example?

Postback is actually sending all the information from client to web server, then web server process all those contents and returns back to client. Example: if (!IsPostback) // generate dynamic form else process submitted data; A postback originates from the client side browser.

What is meaning of postback?

A postback is the exchange of information between servers to report a user's action on a website, network, or app.

What IsPostBack event?

A Postback Event is a string of information that is sent to a network's specific URL that contains information about the post-install event pertinent to the network.

What is a postback advertising?

What is a Postback URL in advertising? A Postback URL is a kind of URL that points to a conversion tracking server or ad network conversion API endpoint. The URL isa conversion tracking server will call when a conversion occurs in order to notify a partner or an other tracking server of the conversion event.


The following is aimed at beginners to ASP.Net...

When does it happen?

A postback originates from the client browser. Usually one of the controls on the page will be manipulated by the user (a button clicked or dropdown changed, etc), and this control will initiate a postback. The state of this control, plus all other controls on the page,(known as the View State) is Posted Back to the web server.

What happens?

Most commonly the postback causes the web server to create an instance of the code behind class of the page that initiated the postback. This page object is then executed within the normal page lifecycle with a slight difference (see below). If you do not redirect the user specifically to another page somewhere during the page lifecycle, the final result of the postback will be the same page displayed to the user again, and then another postback could happen, and so on.

Why does it happen?

The web application is running on the web server. In order to process the user’s response, cause the application state to change, or move to a different page, you need to get some code to execute on the web server. The only way to achieve this is to collect up all the information that the user is currently working on and send it all back to the server.

Some things for a beginner to note are...

  • The state of the controls on the posting back page are available within the context. This will allow you to manipulate the page controls or redirect to another page based on the information there.
  • Controls on a web form have events, and therefore event handlers, just like any other controls. The initialisation part of the page lifecycle will execute before the event handler of the control that caused the post back. Therefore the code in the page’s Init and Load event handler will execute before the code in the event handler for the button that the user clicked.
  • The value of the “Page.IsPostBack” property will be set to “true” when the page is executing after a postback, and “false” otherwise.
  • Technologies like Ajax and MVC have changed the way postbacks work.

From wikipedia:

A Postback is an action taken by an interactive webpage, when the entire page and its contents are sent to the server for processing some information and then, the server posts the same page back to the browser.


Expanding on the definitions given, the most important thing you need to know as a web-developer is that NO STATE IS SAVED between postbacks. There are ways to retain state, such as the Session or Viewstate collections in ASP.NET, but as a rule of thumb write your programs where you can recreate your state on every postback.

This is probably the biggest difference between desktop and web-based application programming, and took me months to learn to the point where I was instinctively writing this way.


Postback happens when a webpage posts its data back to the same script/dll/whatever that generated the page in the first place.

Example in C# (asp.net)

...

if (!IsPostback)
   // generate form
else
   process submitted data;