简体   繁体   English

在ASP.NET MVC 4的ASPX视图中使用UserControls

[英]Using UserControls within a ASPX View in ASP.NET MVC 4

I'm in the process of migrating a traditional ASP.NET Web Form app to ASP.NET MVC 4. I've been migrating this project over by adding new Views to my ASP.NET MVC 4 project that use the ASPX view engine. 我正在将传统的ASP.NET Web窗体应用程序迁移到ASP.NET MVC4。通过将新的视图添加到使用ASPX视图引擎的ASP.NET MVC 4项目中,我一直在迁移该项目。 I then take the code-behind content and put it in a <script language="CS" runat="server"> within the view file. 然后,我将代码隐藏的内容放入视图文件中的<script language="CS" runat="server">中。

My Web Forms project makes use of UserControls for the reusable components. 我的Web窗体项目将UserControls用于可重用组件。 Unfortunately, I can't figure out how to bring these over to my new MVC 4 project. 不幸的是,我不知道如何将它们带到我的新MVC 4项目中。

Can someone please tell or show me how to do this? 有人可以告诉或告诉我该怎么做吗?

您是否尝试将“ Inherits System.Web.UI.Page”更改为“ Inherits System.Web.Mvc.ViewPage”以使其成为视图!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM