tags:

views:

31

answers:

2

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.

A: 

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

orjan
+1  A: 

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.

Min