【发布时间】:2014-01-14 14:20:52
【问题描述】:
我需要在部分页面中呈现列表数据...我有存储过程负责获取菜单列表并在视图中有主 Layoutpage--> 共享文件夹--> 现在我在 masterLayout 页面中呈现部分页面但我没有得到任何结果。我知道部分页面不通过控制器,所以我将如何传递数据?
控制器动作
public ActionResult DisplayFunctionsList()
{
var myList = F_UOF.GetAllFunctions();
return View(myList);
}
存储过程映射(模型)类
public class GetAllFunction_SP_Map
{
public GetAllFunction_SP_Map() { }
[Key]
public int Hierarchy_ID { get; set; }
[Required]
public int ParentID { get; set; }
[StringLength(250)]
[Required]
public string ParentName { get; set; }
[Required]
public int ChildID { get; set; }
[StringLength(250)]
[Required]
public string ChildName { get; set; }
[StringLength(250)]
[Required]
public string Controller { get; set; }
[StringLength(250)]
[Required]
public string Action { get; set; }
}
MasterLayout 页面
@Html.Partial("_DisplayFunctionList_Partial")
部分页面(_DisplayFunctionList_Partial)
@model IEnumerable<DatabaseLayer.StoreProcedures.StoreProceduresMapping.GetAllFunction_SP_Map>
@foreach(var item in Model)
{
@item.ParentName
}
【问题讨论】:
-
“部分页面不通过控制器”是什么意思?您可以在控制器操作中使用
return PartialView(view_name, model);。 -
表示通常从控制器在 actionResult 方法中调用 view() 并在 view(model x) 中传递所有数据或模型
-
您到底想做什么?将对象发送到主布局页面?
-
@toxic,我一直打电话给
PartialView():) -
是 PartialView() 在 materPage 布局中工作;位于文件夹> View-->Shared-->MasterLayout
标签: asp.net-mvc razor partial-views