- Ajax helpers are used to create ajax enabled elements same as we create ajax enabled forms and links which perform requests asynchronously.
- Ajax helpers are extension methods of Ajax helper class which exists in System.Web.Mvc namespace.
- Ajax enabled means based on controller and action.
@Ajax.ActionLink("Load Goods", "GetGoods", new AjaxOptions {UpdateTargetId = "Goods-container", HttpMethod = "GET" })
HTML Output
<a data-ajax="true" data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#Goods-container" href="/Home/GetGoods">Load Goods</a>
Properties for AJAX Helpers
Url
Specify the URL that will be requested from the server.
Confirm
Specify a message that
will be displayed in a confirm dialog to the end user. When user clicks
on OK button in the confirmation dialog, the Ajax call performs.
OnBegin
Specify a JavaScript function name which is called at the beginning of the Ajax request.
OnComplete
Specify a JavaScript function name which is called at the end of the Ajax request.
OnSuccess
Specify a JavaScript function name which is called when the Ajax request is successful.
OnFailure
Specify a JavaScript function name which is called if the Ajax request fails.
LoadingElementId
Specify progress
message container’s Id to display a progress message or animation to the
end user while an Ajax request is being made.
LoadingElementDuration
Specify a time duration in milliseconds that controls the duration of the progress message or animation.
UpdateTargetId
Specify the target container’s Id that will be populated with the HTML returned by the action method.
InsertionMode
Specify the way of
populating the target container. The possible values are InsertAfter,
InsertBefore and Replace (which is the default).
No comments:
Post a Comment