vb.net 在 web.config 中注册用户控件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19904141/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 15:47:02  来源:igfitidea点击:

Register user control in web.config

asp.netvb.netuser-controlsnamespaces

提问by dave

Implementing user controls inside the same project, I am trying to reference them in web.config in order to not include the Register clause in every page.

在同一个项目中实现用户控件,我试图在 web.config 中引用它们,以便不在每个页面中包含 Register 子句。

Registering one single control it is working:

注册一个它正在工作的单个控件:

<pages>
    <controls>
       <add tagPrefix="myApp" src="/Controls/WebUserControl1.ascx" tagName="WebUserControl1"/>
    </controls>
</pages>

But if I try to register all the controls in the namespace, it is not working:

但是,如果我尝试在命名空间中注册所有控件,则它不起作用:

<add tagPrefix="myApp" namespace="myApp.Web"/>

responding with the error:

响应错误:

Unknown server tag 'myApp:WebUserControl1'.

未知的服务器标记“myApp:WebUserControl1”。

I am using VB.NET and I suspect that could be something related with Namespaces. Any ideas?

我正在使用 VB.NET,我怀疑这可能与命名空间有关。有任何想法吗?

回答by Monika

Try with

试试

<add tagPrefix="myApp" namespace="myApp.Web.UI.Controls"/>