C# VisualStudio使用UserControlDesigner而不是CustomDesigner
我有一个ASP UserControlC# VisualStudio使用UserControlDesigner而不是CustomDesigner,c#,.net,asp.net,visual-studio-2008,custom-server-controls,C#,.net,Asp.net,Visual Studio 2008,Custom Server Controls,我有一个ASP UserControlQuestionWithAnswer(.ascx):BaseQuestion:UserControl 还有一个ControlDesignerQuestionDesigner:UserControlDesigner。 现在,我使用DesignerAttribute来关联控件和设计器: [Designer(typeof(QuestionDesigner))] public class BaseQuestion : UserControl 所有类型都在同一程序集
QuestionWithAnswer(.ascx):BaseQuestion:UserControl
还有一个ControlDesignerQuestionDesigner: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");
}
}
好的,已经有答案了: 备注 开发人员没有任何优势 创建自己的设计器 来自UserControlDesigner。增强 一个应用程序的设计时体验 自定义控件,派生控件 来自CompositeControl和您的 设计师来自 复合控件设计者。因为 在这种情况下,您不会使用.ascx文件 用于ASP.NET标记 在我的情况下,不可能更改为CompositeControls。 相信我,我更喜欢复合/网络控制