Visual Studio 使用 UserControlDesigner 而不是 CustomDesigner

发布于 2024-08-23 10:35:06 字数 1491 浏览 4 评论 0原文

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

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 (_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");
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

君勿笑 2024-08-30 10:35:06

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

备注

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

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

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 ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文