共享ASP.NET MVC项目之间的局部视图 [英] Sharing ASP.NET MVC partial views between projects

查看:128
本文介绍了共享ASP.NET MVC项目之间的局部视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是应用程序之间共享一个共同的局部视图的最佳方式?
我已经创建了包含在ASCX文件我偏查看一个单独的程序,一些脚本,这个观点和的HtmlHelper扩展方法去使创建的局部视图更容易。然而,从一个ASP.NET MVC应用程序中引用该程序集时,找不到作为ASCX文件是不可复制的,以及局部视图。此外,什么是包含与应用程序连接的脚本的最佳方式?我可以看到目前唯一的办法是将相关的文件复制到新的应用程序。

What is the best way to share a common Partial View between applications? I've created a separate assembly containing my Partial View in an ascx file, some scripts that go with that view and an HtmlHelper extension method to make creating the partial view easier. However, when referencing that assembly from an ASP.NET MVC application, it can't find the partial view as the ascx file is not copied as well. Also, what is the best way of including the attached scripts with the application? The only way I can see at the moment is to copy the relevant files to the new application.

推荐答案

一个很好的问题,确实如此。

A nice question indeed.

我会建议避免ASCX文件,并在你的HTML辅助手动生成HTML。 TagBuilder类确实帮助很大这里。

I would suggest avoiding ascx files and generating HTML manually in your HTML helpers. TagBuilder class does a great deal of help here.

这篇关于共享ASP.NET MVC项目之间的局部视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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