Ajax. BeginForm asynchronously submits the form and updates the data

Source: Internet
Author: User

using (Ajax.beginform ("Getbasicinformation", "Employee",//
New Ajaxoptions {Updatetargetid = "basicinfo",//sets the ID of the HTML element, and 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 duration of the animation for exposing the element specified by Loadingelementid, in milliseconds
url = url.action ("getbasicinformation"),//Set the requested server-side URL, this effect: If JavaScript is not enabled, create a form element that is passed back to the original action method to ensure graceful demotion
HttpMethod = "Post"},//http method of request

New {@class = "profileform", id = "Basicinformation"})//

{

}

The source code effect in the previous paragraph of the browser is as follows:

<form action= "/employee/getbasicinformation? Length=8 "

class= "profileform" data-ajax= "true"

data-ajax-loading= "#loading"

< Span class= "Webkit-html-attribute-name" > data-ajax-loading-duration= " 3000 "

< Span class= "Webkit-html-attribute-name" > data-ajax-method=" post"

< Span class= "Webkit-html-attribute-name" > data-ajax-mode= "replace"

< Span class= "Webkit-html-attribute-name" > data-ajax-update=" #basicInfo "

< Span class= "Webkit-html-attribute-name" > Data-ajax-url= "/employee/getbasicinformation"

id= "basicinformation" method= "post" >

The code in the controller is as follows:

[HttpPost]
Public Partialviewresult getbasicinformation ()
{

。。。。。。。

。。。。。。。

。。。。。。。

return Partialview ();
}

partialviewresult.ascx is the content of the view you want to refresh

For example:

<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>

Ajax. BeginForm asynchronously submits the form and updates the data

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.