如何显示的WebForms的.ascx如局部视图MVC 3 [英] How to display WebForms .ascx as partial view in MVC 3

查看:167
本文介绍了如何显示的WebForms的.ascx如局部视图MVC 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个新的ASP.NET MVC 3应用程序。在这个应用程序,我想显示在我新的MVC应用程序的剃须刀作为局部视图的覆盖旧的WebForms的用户控件(.ascx / .ascx.cs)。我不能找到在网络上做这样的东西。谁能告诉我,如果这是可能的,如果是这样我指向一些文档?谢谢你。

I am building a new ASP.NET MVC 3 application. In this application, I would like to display an old WebForms user control (.ascx/.ascx.cs) in an overlay in my new MVC razor app as a partial view. I cant find anything about doing this on the web. Can anyone tell me if this is possible, and if so point me to some documentation? Thanks.

推荐答案

这是非常不好的做法,做这样的事情。然而,这可能是由于以下code来实现:

It is very bad practice to do such a thing. However this could be achieved by the following code:

@Html.Partial("_Foo")

然后在你的 _Foo 局部视图,你可以有以下内容:

Then in your _Foo partial view, you could have the following:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<%@ Register Assembly="SomeAssembly" Namespace="SomeNs" TagName="foo" %>

<foo:SomeControl runat="server" ID="fooControl" />

希望这有助于。看看这个问题:

Hope this helps. Have a look at this question:

  • MVC 3: Add usercontrol to Razor view

这篇关于如何显示的WebForms的.ascx如局部视图MVC 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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