Ajax of ASP. NET MVC

Source: Internet
Author: User

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

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.