ajax of ASP . NET MVC
Body:
In addition to HtmlHelper, there are urlhelper help methods:
[Email protected] (): URL string
<a href= "@Url. Action (" Index "," Home ", new {id = +})" > Jump </a><br/>
2.@Url. RouteUrl: Generate URL strings based on route name
@Url. ROUTEURL ("Default1", new {controller = "Home", action = "index", id = +, name = "abc"});
[Email protected] (): Get Routedata (Key-value pair) data (Controller, action, parameters)
@{
var routdata = Url.RouteCollection.GetRouteData (new Httpcontextwrapper (httpcontext.current));
var list = Routdata. Values.tolist ();
foreach (var item in list)
{
@item. Key @:----
@item. value
}
Ajaxhelper How to help:
[Email protected] ():(ajaxoptions chart below)
@Ajax. ActionLink ("Display string", "ActionName", "Controllername", New Ajaxoptions ()
{
Confirm= "Do you want to make a request?",
URL = Url.action ("ActionName", "controllername")
,
HttpMethod = "POST"
,
Updatetargetid = "Displaydiv"//updated HTML element ID
,
Insertionmode = insertionmode.replace//update mode
,
Loadingelementid = "Loading"//element ID displayed at load time
,
onsuccess = "Success"
,
Onbegin = "Begin"
,
OnFailure = "Fail"
,
OnComplete = "Comp"//trigger upon completion
});
[Email protected] (): parameter is the same as @ajax.actionlink () (Ajaxoptions figure below)
Among them ajaxoptions:
Edit the demo with Ajax:
To introduce a script:
The background controller verifies again and edits the operation:
the same webconfig file needs to be confirmed:
END
Ajax of ASP. NET MVC