【问题标题】:Visual Studio uses UserControlDesigner instead of CustomDesignerVisual Studio 使用 UserControlDesigner 而不是 CustomDesigner
【发布时间】:2010-02-26 13:22:00
【问题描述】:

我有一个 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");
    }
}

【问题讨论】:

    标签: c# .net asp.net visual-studio-2008 custom-server-controls


    【解决方案1】:

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

    备注

    没有开发者优势 创建自己的设计师派生 来自用户控件设计器。加强 设计时体验 自定义控件,派生你的控件 从 CompositeControl 和你的 设计师来自 复合控制设计器。在那里面 情况下,您不会使用 .ascx 文件 用于您的 ASP.NET 标记。

    就我而言,不可能更改为 CompositeControls。 相信我,我更喜欢 Composite/WebControls ...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-21
      • 2020-09-19
      • 1970-01-01
      • 2011-11-08
      • 1970-01-01
      • 1970-01-01
      • 2021-09-03
      • 1970-01-01
      相关资源
      最近更新 更多