如何使用Html.Action? [英] How can I use Html.Action?
本文介绍了如何使用Html.Action?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试了解如何使用:
I am trying to understand how to use:
@Html.Action("GetOptions", )
我想做的是将呼叫传递给控制器并传递参数:
What I would like to do is to pass a call to my controller and pass the parameters:
pk = "00" and rk = "00"
有人可以解释一下我如何使用Html.Action
Can someone explain how I can do that with the Html.Action
推荐答案
您应该查看操作方法;解释得很好.对于您的情况,这应该可行:
You should look at the documentation for the Action method; it's explained well. For your case, this should work:
@Html.Action("GetOptions", new { pk="00", rk="00" });
controllerName
参数将默认为从中调用Html.Action
的控制器.因此,如果您尝试从另一个控制器调用动作,则必须指定控制器名称,如下所示:
The controllerName
parameter will default to the controller from which Html.Action
is being invoked. So if you're trying to invoke an action from another controller, you'll have to specify the controller name like so:
@Html.Action("GetOptions", "ControllerName", new { pk="00", rk="00" });
这篇关于如何使用Html.Action?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文