3
我Web.config
已经registered two namespaces这样的:ASP.NET Web窗体:用于Web控件使用相同的TagPrefix从不同的命名空间
<add tagPrefix="a" assembly="WebApplication1" namespace="WebFormsApplication1.Controls1" />
<add tagPrefix="a" assembly="WebApplication1" namespace="WebFormsApplication1.Controls2" />
我在.aspx
页面使用它们像这样:
<a:WebCustomControl1 ID="Control1" runat="server"></a:WebCustomControl1>
<a:WebCustomControl2 ID="Control2" runat="server"></a:WebCustomControl2>
这里的(碎).designer.cs
文件VS生成该页面(请注意,它使用Controls2
命名空间这两个控件,虽然Control1
奠定了在Controls1
命名空间):
protected global::WebFormsApplication1.Controls2.WebCustomControl1 Control1;
protected global::WebFormsApplication1.Controls2.WebCustomControl2 Control2;
它看起来像Web.config中的第二个<add
覆盖第一个。 我想要它追加而不是覆盖,这有可能吗?
我想有其他选择还有:
- 把一切都放在一个单一命名空间
- 使用独特
tagPrefix
每个命名空间
但他们不冷静,因为我们在这里有一个关于控制的hujilion。
注意,如果注册的命名空间中aspx
本身,它会很好地工作:
<%@ Register TagPrefix="a" Namespace="WebFormsApplication1.Controls2" Assembly="WebFormsApplication1" %>
<%@ Register TagPrefix="a" Namespace="WebFormsApplication1.Controls" Assembly="WebFormsApplication1" %>
所以它看起来像在Web.config
解析了一些bug。
(我在VS 2017上,但他们告诉我这是自VS 2010以来发生的事情)。