Problems creating a Designer

Discussion in 'ASP .Net Web Controls' started by Kjetil Nordahl, Nov 9, 2004.

  1. In designview of the WebForm, my control shows the error message: "Error
    Creating Control - ReportDate1 (i)".

    Failed to create designer
    'System.Windows.Forms.Design.ComponentDocumentDesigner,
    System.Design, Version=1.0.5000.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'

    What is wrong?
    The webcontrol is working, but I would like the designer to work too...
     
    Kjetil Nordahl, Nov 9, 2004
    #1
    1. Advertising

  2. Ok. I think I found the problem. It works now, anyway!

    The problem was in the [Designer()] on the control-class.
    the string-parameter to Designer should be:

    [Designer("namespace-name.designerclass-name, assembly-name")]
     
    Kjetil Nordahl, Nov 12, 2004
    #2
    1. Advertising

  3. Kjetil Nordahl

    Kurt Yokum Guest

    Could use drop in a code sample that includes this Designer syntax? I am not
    familiar with where this would go in the code.

    Thanks,
    Kurt

    "Kjetil Nordahl" wrote:

    > Ok. I think I found the problem. It works now, anyway!
    >
    > The problem was in the [Designer()] on the control-class.
    > the string-parameter to Designer should be:
    >
    > [Designer("namespace-name.designerclass-name, assembly-name")]
    >
     
    Kurt Yokum, Nov 12, 2004
    #3
  4. Here is an example on a webcontrol with a designer. This designer should show
    a dropdownlist with the item "design-time item".

    using System;
    using System.ComponentModel;
    using System.IO;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.Design;

    namespace MyCompany.MyControls
    {
    [ToolboxData("<{0}:MyWebControl runat=server></{0}:MyWebControl>"),
    Designer("MyCompany.MyControls.MyWebControlDesigner, MyWebControl")]
    public class MyWebControl : WebControl
    {
    ....
    }

    public class MyWebControlDesigner : ControlDesigner
    {
    public override string GetDesignTimeHtml()
    {
    MyWebControl ctrl = (MyWebControl)Component;

    // create the html-writer
    StringWriter sw = new StringWriter();
    HtmlTextWriter tw = new HtmlTextWriter(sw);

    // add a control that you want to show at design-time
    DropDownList designTimeDropDownList = new DropDownList();
    designTimeDropDownList.Items.Add("design-time item");

    // get design-time styles and formatting from your control
    MyWebControl ctrl = (MyWebControl)Component;
    designTimeDropDownList.CssClass = ctrl.CssClass;

    // let the design-time control render itself on the html-writer
    designTimeDropDownList.RenderControl(tw);

    // return the html-code from the html-writer
    return sw.ToString();
    }
    }
    }

    Also add the following code to the AssemblyInfo.cs-file to get a nice
    tag-prefix (<abc:MyWebControl runat="server" />)

    using System.Web.UI;
    [assembly: TagPrefix("MyCompany.MyControls", "abc")]


    "Kurt Yokum" wrote:

    > Could use drop in a code sample that includes this Designer syntax? I am not
    > familiar with where this would go in the code.
    >
    > Thanks,
    > Kurt
    >
    > "Kjetil Nordahl" wrote:
    >
    > > Ok. I think I found the problem. It works now, anyway!
    > >
    > > The problem was in the [Designer()] on the control-class.
    > > the string-parameter to Designer should be:
    > >
    > > [Designer("namespace-name.designerclass-name, assembly-name")]
    > >
     
    Kjetil Nordahl, Nov 15, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve B.
    Replies:
    4
    Views:
    989
    Cheryl D Wise
    Jun 1, 2007
  2. Alexander Higgins
    Replies:
    3
    Views:
    1,093
    Teemu Keiski
    Jul 30, 2007
  3. Alexander Higgins
    Replies:
    0
    Views:
    457
    Alexander Higgins
    Jul 21, 2007
  4. MRAB
    Replies:
    0
    Views:
    104
  5. Vincent Vande Vyvre

    Re: creating rectangle with qt-designer

    Vincent Vande Vyvre, Sep 20, 2013, in forum: Python
    Replies:
    0
    Views:
    126
    Vincent Vande Vyvre
    Sep 20, 2013
Loading...

Share This Page