Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code behind methods vs. Jquery AJAX calls

Theres a war brewing I can feel it!

Old school coders are used to having every server control create events in the .cs files.. for example.. Getting the Initial load of data, Saving Data, Deleting data... and then binding datasources to the server control..

New school coders want to do it in Jquery + AJAX calls to .svc files... That gives automatic no post backs so that is a advantage... and I think its a different way of thinking.. All of a sudden the UI related events are all being done in Jquery..

What is the most modern and efficient way to go ? How can I convince the old school coders to let us you this new paradigm ? (assuming it is the better way)

like image 475
punkouter Avatar asked May 03 '10 18:05

punkouter


People also ask

Is AJAX better than jQuery?

While JQuery is a library for better client-side web page development, AJAX is a technique of doing XMLHttpRequest to the server from the web page and sending/retrieving data used on a web page. AJAX can change data without reloading the web page. In other words, it implements partial server requests.

What is the difference between AJAX and jQuery?

AJAX is a web development technique for making asynchronous calls to the server. jQuery is a JavaScript library for designing and make some web development tasks easy. It makes it possible to run javascript outside of the browser. It works on the browser or outside the browser also.

Can we call C# code behind using jQuery?

Can we call C# code behind using jQuery? we can but we need to specify the backend method as static . Yes,But it having some prerequisiteC# method mark as webmethod.

Is AJAX better than JavaScript?

AJAX, which is built on comprehensive frameworks and libraries, allows for a more sophisticated extension of JavaScript programming. It is a group of technologies comprised of interrelated development methods that are used not only for web development but also for stand-alone applications.


3 Answers

I would say that ASP.NET MVC and the adoption of jQuery is a response to criticism levelled at the ASP.NET webforms + MSAJAX stack.

Webforms was conceived to try bring drag drop control development to the web in the same way applications were built using Visual Basic, ActiveX and COM. Its created a terribly complex and inefficient way of creating web applications.

Although webforms will be around for a while, MVC + jQuery is the way to go, or even dropping ASP.NET on the server side altogether and just using something like extjs/jqueryUI and WCF web services.

like image 90
James Westgate Avatar answered Oct 05 '22 22:10

James Westgate


It's not a question about old or new. I was using server calls from the client before AJAX and even XmlHttpRequest existed.

It's a matter of what's better suited to do the task. Sometimes you want a server call without reloading the page, sometimes you want to reload the page.

like image 25
Guffa Avatar answered Oct 05 '22 22:10

Guffa


One of the reasons is better using Jquery+AJAX is that you're sending and receiving just the data you need instead of the full postback data travelling to the server and back.

Another reason is esthetic because there is no refreshing on the page, so you have a better user experience.

In the company I used to work, the did some testings on the efficiency between ASP.NET and MVC .NET (for example). I can't send you the graphs and so, but there was an advantage in the use of bandwidth.

I hope it helps

like image 23
Sanchitos Avatar answered Oct 05 '22 22:10

Sanchitos