Register user control in web.config

2019-07-25 13:31发布

问题:

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.

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'.

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

回答1:

Try with

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