简体   繁体   中英

ASP.NET MVC2: Can I return the same PartialView from more than one Action?

I am using PartialView object for all the CRUD operations in my project.

I would like to return from more than one action (Create/Read/Edit) always the same PartialView that I have previously binded to the correct model object.

How can I achieve this?

Thanks

You can specify, which (Partial)View you want to return from an action like this:

return PartialView("ViewName", viewModel);

If you want to use the partial view from different controllers, then put it in the Views/Shared folder.

只需将此添加到您希望从中返回部分操作的每个操作的末尾

return PartialView("PartialViewName", yourModelName)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM