An Ajax asynchronous form of MVC

Source: Internet
Author: User
Tags actionlink

Once learned Ajax, not particularly familiar with the use of the opportunity to learn MVC, a good experience of a, very grateful to the "MVC Development Practice" This book, looked at two or three times, just calculate the entire operation of the MVC mechanism has a certain understanding, the following to share our frequently used in the development of the asynchronous form of the operation.


DEMO

1.VIEW

<span style= "FONT-SIZE:18PX;" >@{Layout = null;} <! DOCTYPE html>


2.Controller

<span style= "FONT-SIZE:18PX;" >//<summary>//Controller//    </summary> public    class Homecontroller:controller    { Public               ActionResult Index ()        {            return View ();        }             <summary>////        asynchronous request method, return the content object of the time///</summary>//        <returns></returns > Public        actionresult GetDate ()        {            System.Threading.Thread.Sleep ($);            Return Content (DateTime.Now.ToString ());        }    } </span>


2. The results show


3. Code Analysis

1. Asynchronous connections

@Ajax. ActionLink () method, several commonly used parameters have been shown in the demo, and have added detailed comments, mainly used to implement asynchronous connection operations. And you can manipulate the content that is returned.

2. Asynchronous forms

Ajax.beginform () method, I have to say, in MVC will often use this method, as the same, the demo has detailed comments, no longer say. For example, when we are doing a login function, we can take an asynchronous form. By submitting a form to the background, and then returning the results of the login in reality to view, it is very convenient.



An Ajax asynchronous form of MVC

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.