[英]designer.cs issues with using user control in Visual Studio
在開發過程中,我有一個Web用戶控件項目和另一個Web項目,它將使用Web用戶控件項目中的用戶控件。
所以我將DocControl.ascx文件復制到我的web項目並嘗試使用DocControl.ascx的屬性。 但VS不知道控件的屬性。 所以當我檢查designer.cs時,引用就是這樣的
protected global::System.Web.UI.UserControl Control;
應該是哪個
protected global::MSN.DocControl Control;
所以我將控件的名稱從System.Web.UI.UserControl更改為MSN.DocControl ,我可以使用DocControl.ascx的屬性。
但我的問題是每當我修改(例如,在aspx中放置一個標簽)aspx文件時,designer.cs中的引用就變成了
protected global::System.Web.UI.UserControl Control;
所以每當我修改我的aspx時我都要改變它。
我該怎么辦,所以我不需要更改designer.cs
提前致謝......
我通過移動解決了它
protected global::MSN.DocControl Control;
從designer.cs到.cs頁面。
因此,無論何時進行任何更改,都可以。
@kokbira - >希望它對你有所幫助。
就我而言,在我的注冊行中它是一個糟糕的src路徑。 這不會導致錯誤消息,但會生成通用控件而不是特定類,具有您描述的相同症狀。
我有這個(它有錯誤的Src路徑):
<%@ Register TagPrefix="uc" TagName="Pipes" Src="/Controls/Pipes.ascx" %>
...
<uc:Pipes id="ucPipes" runat="server" />
它生成了這個,它是通用的,並且沒有控件的屬性:
protected global::System.Web.UI.UserControl ucPipes;
當我使用Category文件夾執行正確的路徑時,它工作正常:
<%@ Register TagPrefix="uc" TagName="Pipes" Src="/Category/Controls/Pipes.ascx" %>
...
<uc:Pipes id="ucPipes" runat="server" />
並生成了這個正確的,所以所有屬性都有效:
protected global::Company.Category.Controls.Pipes ucPipes;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.