Ajax. BeginForm: submits forms asynchronously and updates data. ajax. beginform forms

Source: Internet
Author: User

Ajax. BeginForm: submits forms asynchronously and updates data. ajax. beginform forms

 

Using (Ajax. BeginForm ("GetBasicInformation", "Employee ",//
New AjaxOptions {UpdateTargetId = "basicInfo", // sets the ID of the HTML element. The content received from the server is inserted into the element.
LoadingElementId = "loading", // specifies the ID of the HTML element, which is the HTML element to be displayed during the execution of the ajax request

LoadingElementDuration = 3000, // specifies the animation duration, used to show the elements specified by LoadingElementId, in milliseconds
Url = Url. action ("GetBasicInformation"), // sets the requested server URL. This effect: if JavaScript is not enabled, create a form element that is passed back to the original Action method to ensure elegant degradation.
HttpMethod = "Post"}, // http Method of the request

New {@ class = "profileForm", id = "BasicInformation "}))//

{

}

The source code in the browser in the previous section is as follows:

<Form action = "/Employee/GetBasicInformation? Length = 8"

Class = "profileForm" data-ajax = "true"

Data-ajax-loading = "# loading"

Data-ajax-loading-duration = "3000"

Data-ajax-method = "Post"

Data-ajax-mode = "replace"

Data-ajax-update = "# basicInfo"

Data-ajax-url = "/Employee/GetBasicInformation"

Id = "BasicInformation" method = "post">

 

The Controller code is as follows:

[HttpPost]
Public PartialViewResult GetBasicInformation ()
{

.......

.......

.......

Return PartialView ();
}

PartialViewResult. ascx contains the View content to be refreshed.

For example:

<H2> Basic Information <Span class = "c_edit" id = "spantest"> </span>
<Div class = "basicShow" id = "basicshow">
<Span> <% = Model. NAME %> <% = Model. SEX %> <% = Model. EDUCATION_BACKGROUND %> <% = Model. WORK_EXPERIENCE %> <br>
<% = Model. PHONENUMBER %> <% = Model. EMAIL %> <% = Model. SITUATIONID. SITUATION %>
<Br>
</Span>
<Div class = "m_portrait">
<Div> </div>

</Div>
</Div>

 

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.