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

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

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

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. Dales
    Replies:
    18
    Views:
    1,193
    Jim Cheshire [MSFT]
    Dec 3, 2003
  2. Lloyd Sheen

    HTML Designer Problems

    Lloyd Sheen, Nov 19, 2003, in forum: ASP .Net
    Replies:
    17
    Views:
    839
    Jim Cheshire [MSFT]
    Nov 21, 2003
  3. Jimmy

    designer problems

    Jimmy, Jul 31, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    400
    Jimmy
    Jul 31, 2005
  4. SAL

    Dataset Designer problems

    SAL, Mar 16, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    451
  5. Steve B.
    Replies:
    4
    Views:
    1,207
    Cheryl D Wise
    Jun 1, 2007
  6. Dales
    Replies:
    1
    Views:
    214
    Jacob Yang [MSFT]
    Nov 5, 2003
  7. Alexander Higgins
    Replies:
    3
    Views:
    1,284
    Teemu Keiski
    Jul 30, 2007
  8. Alexander Higgins
    Replies:
    0
    Views:
    614
    Alexander Higgins
    Jul 21, 2007
Loading...