Visual Studio uses UserControlDesigner instead of CustomDesigner
I've got an ASP-UserControl QuestionWithAnswer (.ascx) : BaseQuestion : UserControl
and a ControlDesigner QuestionDesigner : UserControlDesigner
.
Now i use the DesignerAttribute to associate control and designer:
[Designer(typeof(QuestionDesigner))]
public class BaseQuestion : UserControl
all types are in the same assembly (WEB Application). But it still loads UserControlDesigner instead of mine. Did i have to put my designer in a seperate assembly? I suppose the asp-page designer cannot find the designer.
thx! mo
demo code:
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 (_verb开发者_StackOverflow社区s == null)
{
_verbs = new DesignerVerb[]
{
new DesignerVerb("test", onblabla),
};
Verbs.AddRange(_verbs);
}
return base.Verbs;
}
}
private void onblabla(object sender, EventArgs e)
{
MessageBox.Show("blabla");
}
}
okay there is already an answer: http://msdn.microsoft.com/en-us/library/system.web.ui.design.usercontroldesigner.aspx.
Remarks
There is no developer advantage to creating your own designer derived from UserControlDesigner. To enhance the design-time experience for a custom control, derive your control from CompositeControl and your designer from CompositeControlDesigner. In that case, you would not use an .ascx file for your ASP.NET markup.
In my case there is no possibility to change to CompositeControls. Trust me, i prefer Composite/WebControls ...
精彩评论