hey there – I’m trying to use asp.net mvc for some things as usual, but I’ve got a bit of a quandry.
At one point in my application, I need to load a view and pass a specific model through it – this isn’t a huge deal, except that it relates to the existing model. Now then, RenderPartial doesn’t work because that only passes a model and doesn’t actually hit the controller – I need to run back to the controller to pass the model through the ActionResult so that its contents can be returned.
So I thought I would use jQuery. #(‘…’).load(‘/controller/action’) has worked in the past, so why not now? But I need to pass a parameter through it. I’ve tried simply adding…
load(‘/controller/action/’ + <%= Model.Parameter %>) and it didn’t take – so does anyone know how to do this? (or perhaps a better way to do it?)
You can use MVC Futures / ASP.NET MVC 2 which has a RenderAction method, allowing you to go back to the controller. Also you can pass in the model you need for your partial view as a property of the parent view model, my current method. Or store the new model in the ViewData, but this isn’t very strongly typed and not recommended.