0

我有一个 ASP-UserControlQuestionWithAnswer (.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");
    }
}
4

1 回答 1

1

好的,已经有了答案:http: //msdn.microsoft.com/en-us/library/system.web.ui.design.usercontroldesigner.aspx

评论

从 UserControlDesigner 创建您自己的设计器对开发人员没有好处。要增强自定义控件的设计时体验,请从 CompositeControl 派生控件,从 CompositeControlDesigner 派生设计器。在这种情况下,您不会将 .ascx 文件用于 ASP.NET 标记。

在我的情况下,不可能更改为 CompositeControls。相信我,我更喜欢 Composite/WebControls ...

于 2010-02-26T13:50:05.603 回答