【发布时间】:2010-11-14 02:54:20
【问题描述】:
我有一个使用单个 master.page 的网站。在 master.page 中,我有一个名为“ControlPanel”的强类型用户控件 (.ascx)。它的类型是 ControlPanelViewModel。
这里是主页面 - MasterFrame.master:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<body>
<% Html.RenderPartial("ControlPanel"); %> <!-- Here I need to pass the ControlPanelViewModel -->
<!-- main content area -->
</body>
</html>
这里是自定义控制页面——ControlPanel.ascx:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ControlPanelViewModel>" %>
<!-- Some content which are using the ControlPanelViewModel -->
现在的问题是如何将正确的 ControlPanelViewModel 发送到母版页的自定义控件?最好的方法是什么?对于这种情况,是否有某种良好的实践或设计模式?
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-mvc-2