开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜