Call method Summary between MVC views

Source: Internet
Author: User

There are two ways to invoke views:

One: direct call (without controller)

<body>

@Html. Partial (".. /shared/error ");

</body>

Two: Call through controller

<body>

@Html. Action ("Dismode", "Shared")

</body>

Note:

Action, Renderaction Load method of the view, the execution of the Controller→model→view order, and then the resulting page back to the original view and then callback.

Partial, renderpartial Direct load View file contents

Example of invoking a partial view:

Create a new controller: return to partial view
public class Admincontroller:controller
{
Public ActionResult Updateadmin ()
{

      var testObj = newList<string>()

        {

            "aaa""bbb""ccc"

        };


Return Partialview ("Updateadmin", testobj);
}
}
Add a view in the shared folder of views Updateadmin

Several ways to invoke a view
1. Jquery Calls

$ (function () {
$ ("#load"). Load ("/admin/updateadmin");
})

2. Html.action Call
As follows:

@Html. Action ("Updateadmin", "Admin")

3. Direct call without Controller
As follows:
@Html. Partial ("Updateadmin", new List< string > {  "ccc" "ddd" "eee" ) }

Call method Summary between MVC views

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.