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.
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.
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.. :)
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?
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...
Callbacks as in AJAX?
Or do you mean callbacks as in Asynchronous Callbacks of various classes of the .Net framework?
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 :)
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! :)