传递模型Html.Action [英] Passing model to Html.Action

查看:213
本文介绍了传递模型Html.Action的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用asp.net MVC3,我有一个要求远程验证的局部视图。据我所知,这意味着它需要它自己的控制器,所以我用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.

我不希望但对模型仍然传递到Html.Action,就像我会Html.Partial。我怎样才能做到这一点?

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

推荐答案

Html.Action有希望路由值作为对象的重载。你可以尝试传递模式存在和模型绑定将踢。你们的这种做法虽然在期待型模型的参数。

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)

这篇关于传递模型Html.Action的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆