===================ajax.actionlink
The ActionLink method can create an anchor label with one-step behavior.
For example:
Give the page a link, click on the link to display the information on the current page, instead of opening a new page
-- View Code:
@Ajax. ActionLink ("Ajax",//Page link name "Getajax",//Controller in method new ajaxoptions{Updatetargetid = "Getajax",//label to replace INSERTIONMO de = insertionmode.replace,//insert mode: replace label HttpMethod = "Get"//get request}) <!--manipulated label--><div id= "Getajax" ></ Div>
-- Controller code: (Returns a partial view to the foreground, need to create a getajax.cshtml view in the view)
Public ActionResult Getajax () {return this. Partialview ();}
===================ajax form
Case: Querying Data asynchronously
-- View Code:
<!--Ajax execution fails when executing a script--><script> function loadfailure () { $ ("#div1"). Text ("Failed to load"); }</script>@ using (Ajax.beginform ("Personsearch",//Controller method "Personerror",//Controller new ajaxoptions () { //ajaxoptions object httpmethod= "Get",//Submission method insertionmode = insertionmode.replace,//Insert mode: Replace label updatetargetid = "Div1",//Operating label LoadingElementId = "Ajax-load",// When you click the Submit button, a status of the load is displayed (GIF loading image is used here) onfailure= "Loadfailure"//execute a script when Ajax execution fails)) { <input type= "text" name= "Q" /> <input Type= "Submit" value= "commit" /> <!--loading status (GIF loading image is used here)--> }<!--operated label-- <div id= "Div1" ></div>
-- Controller code:(return a partial view to the foreground, you need to create a personsearch.cshtml view in the View )
Public ActionResult Personsearch (string q) {var list = db. Schooltypes.where (r = r.st_name = = q). Select (r = r). ToList (); return Partialview (list);}
This article is from the "program Ape's Home--hunter" blog, please be sure to keep this source http://962410314.blog.51cto.com/7563109/1609688
MVC3----Ajax Helper method