Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing model to Html.Action

Using asp.net MVC3, I have a partial view which requires remote validation. As I understand it this means it needs it's own controller, so I'm using Html.Action to call this view and it's controller.

I do however wish to still pass a model to Html.Action, just like I would with Html.Partial. How can I do this?

like image 757
Jonathan Avatar asked Dec 22 '11 18:12

Jonathan


1 Answers

Html.Action has an overload that expects route values as an object. you could trying passing the model there and model binding will kick in. Your action has to be expecting a parameter of type Model though.

Html.Action("ActionName","ControllerName", Model)
like image 188
scartag Avatar answered Nov 11 '22 03:11

scartag