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以來發生的事情)。