AJAX Functionality - ajax

In order to enable AJAX Functionality , which control is placed on the page..?

For AJAX functionality the page (i.e. it's Javascript) uses the XMLHttpRequest object.

If you're talking about ASP.NET, you'll need the ScriptManager and the UpdatePanel.

The main AJAX control that you have to add to your web pages in order to enable ASP.NET AJAX functionality is the ScriptManager control.
If you have master pages you may also use ScriptManagerProxy control.
After adding ScriptManager on to a page, you can add other ASP.NET AJAX controls on the page.
On the other side, if you are just looking for generix AJAX style functionality, you have the JavaScript XMLHttpRequest object.

Related

Links postbacks to the same page?

I have multiple links on my page, when i click on any link, it first loads the same page using get or post and then go to the clicked url. I want to avoid the postback to the same url, what can be done?
Note, My application uses Telerik controls.
This is completely going to depend on which Telerik controls you are using but the general rule of thumb would be to use the OnClientClicking (see Telerik Documentation) using set_cancel(true); to prevent a postback.
If your links aren't telerik controls you could use javascript or JQuery (if being used) to cancel the postback using the onclick event and return false; to cancel the postback.

ASP.NET MVC submit form

I know two ways of submitting form data: by having a button of type submit or by an AJAX post call. What is the difference between those two regarding performace?
This is a very general question, so here is a very general answer.
If you implement the AJAX call efficiently on the server, then you can expect AJAX to be more performant (when measured on the server) than a full page round-trip.
For instance, if you use ASP.NET, clicking a button to submit a page will cause a POST of the form data and a complete re-buildup and rendering of the page. That is not necessary with an AJAX call, if you use real AJAX and not the Microsoft AJAX Control Toolkit for ASP.NET.
Better to use Ajax.BeginForm instead of Html.BeginForm. It will prevent the full postback and will improve the performance.
Ajax POST
Ajax post prevents reload and postback.İt sends data to controller.
Form Data
İt occurs reload page and postback.İt sends data to controller.

How do I programmatically refresh a view page with AJAX?

I wrote a custom link in my page which created by views module, I want to click it to do something, then the page will refresh by ajax, how do I implement this?
I am sorry I didn't express myself clearly, I use Drupal 7, and the Views module to custom my own page.
You can use this module https://www.drupal.org/project/views_refresh or just use the code below in your JS to refresh the view.
$('.view-dom-id-403402eee35f68cd32fe87b45702dc63').triggerHandler('RefreshView');
Attach an event to the link, and when that is fired, execute an AJAX request.

Two forms (one in layout and one in Page) how to handle in asp.net mvc3

I am working on a mobile website in ASP.NET MVC3. I have a page where i have search bar in my header. this header is coming from my Layout page which is common to all other Views. And inside my specific page, I have page specific content(forms).
For my Customer/Add action, I return the Add View of Customer which is strongly typed to my CustomerViewModel. I will have form tag in my Add View which will be posted to HttpPost Add Action method when form gets submitted. That is fine. My question is how will i handle the search box content ? I believe only one form is allowed in the page.So if i have a SearchViewModel which is binded to my Search View(Partial), It is going to be 2 forms in my page. So i can not do that.
I can handle the search part by reading the content in java script and calling another action to get Search results.Is that the only way to do that ? I am worried about those devices where java script is disabled. What should i do ? Please advice
No. You can have more than 1 form on the page. In fact, here you should. Your Add Customer page should submit to 1 action method, but your search form should submit to a different action method.
If you are familiar with webforms, that framework only allows you to have 1 form on the page, but not because HTML requires it. Webforms requires it because it is the only way the framework can carry all of the data from various server controls across POST requests (using ViewState). Webforms has historically not been very HTML or HTTP friendly.
You just can't have forms nested within other forms in HTML, but it is completely legal (and recommended in MVC) to have more than 1 form on a page.
As for AJAX, I would not worry about devices that do not have javascript enabled. There are only like 6 or 7 people on the planet that don't have javascript on their web devices, and if someone disables javascript, they won't be able to experience 99% of the rest of the web anyhow.

How to use ajax tabcontainer in formview?

How to add a tabcontainer in a formview template? I am sure i have a scriptmanager inside the page. but it keep compliaint "A ScriptManager is required on page to use ASP.NET AJAX Script Components. I have also tried move the ScriptManager inside the itemTemplate but same error.
Perhaps you are not using the ToolkitScriptManager?
It's required for Ajax Toolkit components.

Resources