Can I return to the controller when loading a partial view? - asp.net MVC
I have a partial view that I want to basically "take care of itself" and not have 开发者_运维百科to pass it a preloaded Model from my parent view other than a single ID.
My partial view would then take the ID and load the relevant data from a db using code in the controller and pass it back to its view to display it.
I think what you're looking for is RenderAction.
http://davidhayden.com/blog/dave/archive/2009/04/04/ASPNETMVCPartialViewsHtmlRenderActionASPNETMVCFutures.aspx
It's not built in as you'll need the futures.
Yes it's possible
Pass the id
<% Html.RenderPartial("MyPartial", ViewData.Model.Id); %>
Then you have to use ajax in your partial asking the controller for data see:
http://docs.jquery.com/Ajax
精彩评论