[英]Program uses Microsoft Visual Studio folder instead of relative path
[英]Visual Studio uses UserControlDesigner instead of CustomDesigner
我有一个ASP-UserControl QuestionWithAnswer (.ascx) : BaseQuestion : UserControl
和ControlDesigner QuestionDesigner : UserControlDesigner
。 现在,我使用DesignerAttribute来关联控件和设计器:
[Designer(typeof(QuestionDesigner))]
public class BaseQuestion : UserControl
所有类型都在同一程序集中(WEB应用程序)。 但是它仍然加载UserControlDesigner而不是我的。 我是否必须将设计师安排在单独的组装中? 我想ASP页设计器找不到设计器。
谢谢! 莫
演示代码:
public class FragenDesigner : UserControlDesigner
{
private DesignerActionList _actionList;
private DesignerVerb[] _verbs;
public override DesignerActionListCollection ActionLists
{
get
{
if (_actionList == null)
{
_actionList = new DesignerActionList(new System.Windows.Forms.TextBox());
_actionList.AutoShow = true;
ActionLists.Add(_actionList);
}
return base.ActionLists;
}
}
public override DesignerVerbCollection Verbs
{
get
{
if (_verbs == null)
{
_verbs = new DesignerVerb[]
{
new DesignerVerb("test", onblabla),
};
Verbs.AddRange(_verbs);
}
return base.Verbs;
}
}
private void onblabla(object sender, EventArgs e)
{
MessageBox.Show("blabla");
}
}
好的,已经有了答案: http : //msdn.microsoft.com/zh-cn/library/system.web.ui.design.usercontroldesigner.aspx 。
备注
从UserControlDesigner派生自己的设计器没有开发者优势。 若要增强自定义控件的设计时体验,请从CompositeControl派生您的控件,并从CompositeControlDesigner派生您的设计器。 在这种情况下,您将不会在ASP.NET标记中使用.ascx文件。
就我而言,不可能更改为CompositeControls。 相信我,我更喜欢Composite / WebControls ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.