我有一个名为:
的.Net项目Whatever.Web.UI:我使用这个项目来放置将在所有网站项目中重用的所有自定义和用户控件。它们分为两个文件夹:
- CustomControls folder (with all the custom controls)
- UserControls folder (with all the user controls)
这是应该使用这些用户和自定义控件的Web项目的未来示例
Whatever.Web.UI.WebSite1 Whatever.Web.UI.WebSite2 .... .... .... Whatever.Web.UI.WebSiteN
要在每个WebSite项目中使用自定义控件都不是问题,我使用以下方式在web.config中注册:
<add tagPrefix="CustomControls" namespace="Whatever.Web.UI.CustomControls" assembly="Whatever.Web.UI"/>
但是,为了显示每个网站,我怎么能注册用户控件计数他们有一个我需要引用的ascx部分?
提前致谢。 亲切的问候, Josema。
答案 0 :(得分:1)
<system.web>
<pages>
<controls>
<add src="~/UserControls/MyControl.ascx" tagName="MyControl" tagPrefix="MyControls"/>
</controls>
</pages>
</system.web>