Alternative to Updatepanel in ASP.net - asp.net

I want to know whether there is any better option to perform AJAX operations in my ASP.net webforms other than Updatepanel.
Because updatepanel sends lot of viewstate data in the request which in term affects the peroformace of the Application.
Thank You in Advance

You have a few options. You can disable ViewState, or you can use "plain AJAX".
If you choose to use "plain AJAX", you can write your low level JavaScript code or use libraries such as jQuery to make the AJAX calls easier.
On the server side, you'll need to expose some kind of endpoint for the AJAX calls to communicate to. Some people use WebMethod, but that has been deprecated and I would avoid this approach. You can use ASP.NET Web API in .NET 4.5, or in any version of .NET you can use handlers or generic handlers (.ashx) to expose endpoints.

Related

Is the ASP.NET Ajax Library dead?

I've recently stumbled across a few blogs that say the ASP.NET Ajax Library is dead, in particular:
http://encosia.com/2010/10/04/understanding-jquerys-impact-on-microsoft-and-asp-net/
http://weblogs.asp.net/toddanglin/archive/2010/04/19/microsoft-ajax-client-library-is-dead-long-live-jquery.aspx
Is this generally true, technically and practically?
I've been to Microsoft talks on jQuery, and basically it sounded to me like they expected everyone to use jQuery for client-side-only DOM manipulation and ASP.NET Ajax was still used for it's Ajax components (like UpdatePanel) and as a basis for AJAX into .NET services made with WCF or just back to ASHX or other server code.
From being a component developer that targets ASP.NET, I can tell you that it's very much used by our customers, and we need to support it.
Yes, it is. Even for SharePoint developers (which uses ASP.net AJAX heavily) it's out of favor.
However, the SERVER SIDE ASP.net AJAX (UpdatePanel etc.) are alive and kicking. They have some shortcomings (UpdatePanel can send tons of viewstate back and forth).
But the Client Side Framework and ASP.net AJAX Library is dead.
Scalable comet ajax is more popular now. Try the samples of PokeIn library.
A technology can't die if it's customer base is so big!

Does asp.net ajax needs XML http?

Ajax needs xmlhttp. Does Asp.net ajax, ajaxcontrol toolkits also needs xmlhttp for their smooth running.
Depending on the browser it will use either the built-in XmlHttpRequest object or an ActiveX control.
Ajax is XMLHttpRequest, so in short, yes ASP.Net needs that (or ActiveX for IE).
Yes, this is the browser component that AJAX uses to makes requests to the server. The AJAX Toolkit, or more specifically any control that gets data from the server, would require it. However, the way the toolkit runs...I'm not sure if any controls will run with it disabled, as the base set of client scripts expects it to be enabled.
You can read more about how AJAX utilizes XMLHttpRequest object here.

What are the pros and cons when choosing ajax enabled WCF service in an asp.net webform application?

I have just experimented my first ajax enabled WCF service in a sample asp.net webform application... If i have 10-15 pages in my webapplication which involves add,edit,view and delete operations, is it possible to make them ajax post and get without using .cs(codebehind) of all pages...
What are the pros and cons when choosing ajax enabled WCF service in an asp.net webform application?
At first, if you want to implement the server side of jQuery Ajax calls, you can do this with either ASMX or WCF services. You can find a short comparison between these two here. WCF is more modern technology and will be my preferred choice for new projects. It can provide you with the following:
Help you program against an interface
It will serialize/deserialize objects to JSON for you. No need for JSON libraries
Provides client methods that you can use (via the ScriptManager). It is also easy to use jQuery if you prefer
As an disadvantage I would say that it will take you some time to learn the technology. I found that proper configuration of web.config was a little tricky.
I usually have a single svc service that serves all Ajax requests. You can implement as many methods as you want in a single service. The services are called from different pages.

Call a webservice in asp.net ajax

How can I calling a webservice not written by me from asp.net ajax. What's the latest and best way of doing it?
Call the Sys.Net.WebServiceProxy invoke Method
Details here
ASP.NET AJAX is not the preferred library any more. Use jQuery instead which also supports jsonp which is what you will need to call cross-domain web services from the client.

Using jQuery in ASP.NET

When using the AJAX functionality in jQuery, do I also have to have ASP.NET AJAX/.NET 3.5 installed also? or can I only use ASP.NET AJAX?
I'm unclear on whether or not I'm able to use AJAX in ASP.NET without ASP.NET AJAX or not.
No, you don't need ASP.NET AJAX installed to use the AJAX functionality of jQuery.
You can call PageMethods and Web Services without needing a ScriptManager control (which generates the JavaScript proxy objects that allow you to use familiar syntax to call web services and page methods).
Article on using jQuery to directly call ASP.NET AJAX page methods
Article on using jQuery to Consume ASP.NET JSON Web Services
Let me first clarify the use of jQuery. jQuery is simply a javascript library, and it has nothing to to with ASP.NET or any other server side platform such as PHP or JSP.
So you can simply use jQuery side by side with ASP.NET, or even combine jQuery with ASP.NET 3.5 that has AJAX built in.
You can also use jQuery's AJAX if you like, and it still can run in ASP.NET. If you want to combine both, please test your aspx page first if you also want to use ASP.NET's UpdatePanel with jQuery's AJAX, since it can bring incompatibilities between them.
No, if you're using jQuery you don't need ASP.NET AJAX installed.
ASP.NET Ajax is not needed in order to use jQuery, but the two work well together, hence the support from Microsoft.

Resources