views:

320

answers:

6

Why do we need callbacks in ASP.NET or any server side technology?

One answer can be, to achieve asynchronous calls. But I am not interested in its technological perspective. Please tell me the philosophical perspective.

A: 

If you want to perform actions on the clientside after the server returned a response, you'd need a clientside callback function... It doesn't all work by itself.. :)

Ropstah
Not a very clear answer. Can you please elaborate a little?
JMSA
You can send information to the webserver from the clientside. Very nice, the server can perform actions and write stuff to the database. And then? Maybe nothing. The user sees the updated information on the website next time he visits (or if he reloads the page). But what if you (website owner) want to immediately change the content on the website (based on the users input). Then you'd need some code to perform just that... You wrap that code in a function that the original code can call when it receives information from the server - or when it can be called back...
Ropstah
Why are you downvoting? People are trying to help, but you're not being a very good questioner..
Ropstah
I haven't voted. May be somebody else!
JMSA
My bad, cdonner was thinking the same.. Maybe cause the question got changed the answers looked awkward
Ropstah
+5  A: 

To begin with Descartes' "Cogito, ergo sum", a web page cannot think. How does a web page prove that it exists? Does the web even exist, or is it just a product of our imagination? To resolve this dilemma, Ajax and client-side callbacks come to the rescue. A web page can call back to the server, and the server will confirm that it actually exists.

What's all these commentless down-votes for? Am I not philosophical enough?

cdonner
Maybe take it easy on the psychotropic drugs before coming on the internet. Can you do that for <st>me</st> the entire internet?
belgariontheking
People often forget this from the FAQ... 'Bring your sense of humor'
Chalkey
I second cdonner, a question like the one above needs an answer like cdonners (or mine :P). A search on Google 'why do we need client side callback' gives very good results offering the questioner perfect answers to his question. However, he wants a philosophical answer. I thought I was creative, but cdonner blows me away. He gets my vote
Ropstah
Well, he did ask for the philosophical perspective
Fredrik Mörk
P.S. So I up'd you back...
Chalkey
I can't understand Why you are blaming me! I haven't achieved required points to cast vote yet! !!!!!!!
JMSA
Not blaming you, just the people who down-vote and don't have the guts to identify themselves.
cdonner
A: 

ASP.NET happens on the server, A client-side callback happens on the client in javascript...

Both things don't really have a lot to do with each other...

fretje
Boo! Boo! Boo!Boo! Boo! Boo!
JMSA
The title had "client-side callback" in there when I was typing my answer... Maybe you can clarify your question a bit more?
fretje
Also, I don't think this is the right site for philosophical questions...
fretje
+1  A: 

Callbacks as in AJAX?

  1. Slight improvement in server performance. If I want to update my status on facebook why force the server to generate the entire page all over again?
  2. More robust UI experience. Controls are more responsive and behaviors are more like desktop form applications.

Or do you mean callbacks as in Asynchronous Callbacks of various classes of the .Net framework?

Spencer Ruport
A: 

Imagine you had two drop down box's, one countries, the other cities. When selecting a different country, the list of cities could be populated by calling the server, getting a new list of cities, sending it back, where the client could update our cities box - thus avoiding the need to reload the whole page just to populate one box :)

Chalkey
A: 

Because the web is a stateless environment, and if you want your website to be able to respond to its users, some form of callback is required.

The benefit of a client side callback (I assume you're speaking of AJAX since you talked about asynchronous operations), is that your website appears more like a native desktop application. By this I mean that when a user interacts with your the UI, they expect a logical operation to occur. When you perform this function on the client side, there is no need to post back the entire page. You can simply reload or change the section that is pertinent to their actions.

Sure there are situations where AJAX isn't needed or it may be overkill, but I like to think that a little bit of well-used AJAX can make things a lot easier on your users, which is the end goal, right? Postbacks are evil! :)

Scott Anderson