2
我正在混合Mvc和webforms,并且想要将Mvc Viewbag对象传递给一个webforms用户控件,该控件不适用于我的方法,如下所示。有没有办法将Viewbag对象从Mvc传递给webforms usercontrol代码隐藏?
<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Register Src="~/Views/Shared/_LengthsAndColors.ascx" TagPrefix="cc1" TagName="_LengthsAndColors" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<cc1:_LengthsAndColors runat="server" Source="<%= ViewBag.Source %>" ID="_LengthsAndColors1" />
</body>
</html>
有没有人有一个想法如何做到这一点?
感谢您的建议罗伊。但是,您能否用短代码说明您的意思? – user3526092 2014-10-08 08:20:37