繁体   English   中英

designer.cs在Visual Studio中使用用户控件的问题

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM