Ajax. actionlink usage

Source: Internet
Author: User
Tags actionlink

The actionlink method of the Ajax attribute can create an anchor tag with asynchronous behavior.
The first parameter of the actionlink method specifies the link text, and the second parameter is the name of the operation to be called asynchronously. Similar to the HTML-assisted method with the same name, the Ajax-assisted method actionlink also provides a variety of overloaded versions to pass the Controller name, route value, and HTML features.

Use:
1. @ Ajax. actionlink ("Homepage", "Index", "home", new ajaxoptions () {updatetargetid = "body_content", httpmethod = "Post", insertionmode = insertionmode. replace}) Ajax describes how to use it. updatetargetid is used to update the content of our presentation layer. httpmethod does not need to be known. We will briefly introduce insertionmode, which is described by Microsoft as an enumeration Ajax script insert mode. We find that there are three insertionmode enumerations (insertafter, insertbefore, and replace) that are hard to understand. Before insertafter is inserted, after insertbefore is inserted, replace is the replaced content, so we can analyze that the above method asynchronously refreshes the content of the body_content layer. Obviously, we can analyze some of their application scenarios based on these content. Data Table updates and other content updates. It is more convenient to append data here. We are looking at the usage of ajaxactionlink.
2. Confirm: we can see this attribute and obtain or set the message displayed in the confirmation window before the request. It is not hard to understand that we can use this content to implement the alert message prompt function. (Is there a way to get rid of JavaScript? In fact, the mechanism is still JavaScript)
3. oncomplete, onsuccess, onfailure, and onbegin. We found that the content is also included. The first sight is a time method. However, in Ajax. actionlink. It is also the result content returned for our processing method. We use the front-end JavaScript to complete the processing, the processing is successful, the processing fails, and other information corresponds to the business content.
The process is as follows:
@ Ajax. actionlink ("Homepage", "Index", "home", new ajaxoptions () {updatetargetid = "body_content", httpmethod = "Post", onsuccess = "show ()", onfailure = "failure ()"})
<SCRIPT>
Function show (){
/// What do you want to deal?
}
Function failure (){
/// What do you want to deal?
}
</SCRIPT>
4. url: Get or set the URL of the rendered page
All methods are as follows:

Confirm gets or sets the message displayed in the confirmation window before submitting the request.
Httpmethod gets or sets the HTTP Request Method ("get" or "Post ").
Insertionmode gets or sets the mode that specifies how to insert the response to the target Dom element.
Loadingelementid gets or sets the ID characteristics of the HTML element to be displayed when loading Ajax functions.
Onbegin obtains or sets the name of the JavaScript function called before the page is updated.
The JavaScript function to be called after oncomplete obtains or sets the instantiated response data but before the page is updated.
The JavaScript function to be called when onfailure fails to get or set page updates.
The JavaScript function to be called after onsuccess obtains or sets the page to be updated successfully.
Updatetargetid gets or sets the ID of the DOM element to be updated by the application server response.
URL gets or sets the URL to send a request to it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.