在局部视图传递参数 - MVC3 /剃须刀 [英] Passing parameters in partial Views - MVC3/Razor

查看:162
本文介绍了在局部视图传递参数 - MVC3 /剃须刀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以传递参数在MVC3(剃刀)的局部视图。我换成一个普通视图页面,在我的MVC项目的局部视图。对于普通视图页面,我通过像

How can I pass parameters to a partial view in MVC3 (razor). I replaced a regular View page with a Partial View in my MVC project. For a regular View page, I passed parameters like

   public ActionResult MeanQ(int id)
    {            
        Access access= db.Access.Find(id);
        return View(access);
    }

现在,因为我改变了看法,以局部视图,我有以下的code来代替:

Now since I changed the view to a partial view, I have the following code instead:

  public ActionResult MeanQ(int id)
    {            
        Access access= db.Access.Find(id);
        return PartialView("_MeanQPartial");
    }

但不知道我怎么还传递参数'ID',使其像以前一样工作。请帮忙。什么它的价值,视图或局部视图,二者通过一个链接触发并显示在一个jQuery模态对话框。

but do not know how I can still pass the parameter 'id' to make it work like before. Please help. For what its worth, the View or the partial View , both are triggered by a link and displayed in a Jquery Modal Dialog box.

推荐答案

试试这个

return PartialView("PartialViewName", access);

这篇关于在局部视图传递参数 - MVC3 /剃须刀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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