0

快速回顾:我有一个汽车网站,我有一个简单的ActionResult授权每个有权访问该控制器的用户都将拥有 1 辆汽车,无论是宝马、本田、福特还是起亚,因此一旦他们登录,他们就会看到自动制造汽车。我已经设置了 PartialView 但我的问题是如何从 ActionResult 调用 PartialView 并将其放入视图中的 DIV 中?

 [Authorize]
    public ActionResult Mycars()
    {

// How can I return a PartialView here and put it inside a DIV like
// the partialview is called "Mymakes" and its a PartialViewResult
// I just can't seem to put it inside a DIV from here
        return View();

    }

如前所述,PartialViewResult完美运行我已经使用 Ajax.BeginForm 对其进行了测试,现在只是尝试在 ActionResult 中自动呈现它,任何提示都会很棒!

4

1 回答 1

0

在您的主视图 ( Mycars) 中,使用@Html.Action()

你将在你的控制器中创建相应的动作(你可以设置属性[ChildActionOnly],它可以是类型PartialViewResult

然后,您将创建View与 that 相对应的(部分) PartialViewResult,并且......就是这样。

于 2013-10-11T23:22:58.957 回答