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