Composite control not appearing in toolbar...

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Composite control not appearing in toolbar...

    Hi - I'm just experimenting and following the example in:
    [url]http://msdn2.microsoft.com/en-us/library/ms379565.aspx[/url]

    I have a solution that has my controls project and a "test" web project.

    When I build the controls project, the control that inherits from
    "WebControls" appears fine in the toolbox, but the one that inherits from
    "CompositeControl" does not appear.

    Code for this control is below (just in case I've deviated from the MSDN
    example and not spotted it).

    Thanks for your help.

    Griff
    ------------

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace WebControlLibraryPrototypeA
    {
    [DefaultProperty("Prompt")]
    [ToolboxData("<{0}:AgeCollector runat=server></{0}:AgeCollector>")]
    public class AgeCollector : CompositeControl
    {
    [Bindable(true)]
    [Category("Appearance")]
    [DefaultValue("Please enter your date of birth:")]
    [Description("Text to prompt user with")]
    [Localizable(true)]
    public virtual string Prompt
    {
    get
    {
    String s = (String)ViewState["Prompt"];
    return ((s == null) ? String.Empty : s);
    }

    set
    {
    ViewState["Prompt"] = value;
    }
    }

    [Bindable(true)]
    [Category("Appearance")]
    [Description("Date of birth input area")]
    public virtual DateTime DateOfBirth
    {
    get
    {
    object o = ViewState["DateOfBirth"];
    return (o == null) ? DateTime.Now : (DateTime)o;
    }
    set
    {
    ViewState["DateOfBirth"] = value;
    }
    }

    protected override void CreateChildControls()
    {
    Label lab1 = new Label();
    lab1.Text = Prompt;
    lab1.ForeColor = this.ForeColor;
    this.Controls.Add(lab1);

    Literal lit = new Literal();
    lit.Text = "<br/>";
    this.Controls.Add(lit);

    TextBox tb = new TextBox();
    tb.ID = "tb1";
    tb.Text = DateOfBirth.ToString();
    this.Controls.Add(tb);

    base.CreateChildControls();
    }
    }
    }




    Griff Guest

  2. Similar Questions and Discussions

    1. Toolbar Button not Appearing in Plugin
      The following code is not producing a button in the file toolbar in Acrobat 8 Professional, despite being called from PluginInit: bool...
    2. Losing Composite Control property that another Composite Control ...
      Hi, I'm creating 2 composite controls in ASP.net. Control 1 is a Search control and control 2 is a Map control. I have added a property...
    3. Datagrid and IE Control Toolbar Composite Control
      i have a datagrid and toolbar and have integrated them in my composite control(inherited datagrid) toolbar items are shown as for e.g...
    4. Composite Control with Datagrid and Microsoft IE Toolbar
      Ive developed a composite control that generates Microsoft IE Toolbar and datagrid when we add toolbar items it goes like this "FooterToolBarItems"...
    5. Possible to create a composite control that has a child control that is a validator that validates the composite control itself?
      I am attempting to create a composite control which has a label, followed by an optional error message, followed by two text boxes. I have...
  3. #2

    Default Re: Composite control not appearing in toolbar...

    Bit more info...if I right click in the toolbox and chose "show all" then
    this control appears, albeit greyed out. It's as if it compiled
    successfully but can't be used.


    Griff Guest

  4. #3

    Default Re: Composite control not appearing in toolbar...

    Be sure you have your namespace set properly in the AssemblyInfo.

    [assembly: TagPrefix("CustomNamespace.Controls", "cnc")]

    It should match up with your controls.

    And sometimes Visual Studio needs a restart. There are lots of bugs in
    VS which have been addressed by the SP1 Beta.

    You can get that beta here...

    [url]http://connect.microsoft.com/visualstudio[/url]

    Brennan Stehling
    [url]http://brennan.offwhite.net/blog/[/url]

    Griff wrote:
    > Hi - I'm just experimenting and following the example in:
    > [url]http://msdn2.microsoft.com/en-us/library/ms379565.aspx[/url]
    >
    > I have a solution that has my controls project and a "test" web project.
    >
    > When I build the controls project, the control that inherits from
    > "WebControls" appears fine in the toolbox, but the one that inherits from
    > "CompositeControl" does not appear.
    >
    > Code for this control is below (just in case I've deviated from the MSDN
    > example and not spotted it).
    >
    > Thanks for your help.
    >
    > Griff
    > ------------
    >
    > using System;
    > using System.Collections.Generic;
    > using System.ComponentModel;
    > using System.Text;
    > using System.Web;
    > using System.Web.UI;
    > using System.Web.UI.WebControls;
    >
    > namespace WebControlLibraryPrototypeA
    > {
    > [DefaultProperty("Prompt")]
    > [ToolboxData("<{0}:AgeCollector runat=server></{0}:AgeCollector>")]
    > public class AgeCollector : CompositeControl
    > {
    > [Bindable(true)]
    > [Category("Appearance")]
    > [DefaultValue("Please enter your date of birth:")]
    > [Description("Text to prompt user with")]
    > [Localizable(true)]
    > public virtual string Prompt
    > {
    > get
    > {
    > String s = (String)ViewState["Prompt"];
    > return ((s == null) ? String.Empty : s);
    > }
    >
    > set
    > {
    > ViewState["Prompt"] = value;
    > }
    > }
    >
    > [Bindable(true)]
    > [Category("Appearance")]
    > [Description("Date of birth input area")]
    > public virtual DateTime DateOfBirth
    > {
    > get
    > {
    > object o = ViewState["DateOfBirth"];
    > return (o == null) ? DateTime.Now : (DateTime)o;
    > }
    > set
    > {
    > ViewState["DateOfBirth"] = value;
    > }
    > }
    >
    > protected override void CreateChildControls()
    > {
    > Label lab1 = new Label();
    > lab1.Text = Prompt;
    > lab1.ForeColor = this.ForeColor;
    > this.Controls.Add(lab1);
    >
    > Literal lit = new Literal();
    > lit.Text = "<br/>";
    > this.Controls.Add(lit);
    >
    > TextBox tb = new TextBox();
    > tb.ID = "tb1";
    > tb.Text = DateOfBirth.ToString();
    > this.Controls.Add(tb);
    >
    > base.CreateChildControls();
    > }
    > }
    > }
    Brennan Stehling Guest

  5. #4

    Default Re: Composite control not appearing in toolbar...

    Hi Brennan

    I'm not completely convinced that there is a problem with the namespaces -
    the other controls that inherit from WebControl within the same control
    library all appear. However, I did explicitly add it to the AssemblyInfo
    (and "Using System.Web.UI" but to no avail.

    I'll look into SP1 beta, though again I'm not that happy about using beta
    software. If it is a problem with the IDE then this tells me one of two
    things:
    a) there are a lot of people writing composite controls that are
    experiencing the same problem and PRESUMABLY have found a way around this
    problem before SP1Beta was released, or
    b) there aren't that many developers creating composite controls....

    I'm still hoping that it's just a silly mistake on my part....

    Griff


    Griff Guest

  6. #5

    Default Re: Composite control not appearing in toolbar...

    On 9 Oct 2006 13:16:22 -0700, "Brennan Stehling" <offwhite@gmail.com>
    wrote:
    >Be sure you have your namespace set properly in the AssemblyInfo.
    >
    >[assembly: TagPrefix("CustomNamespace.Controls", "cnc")]
    >
    >It should match up with your controls.
    >
    Hi,

    I just installed beta1 and still have the same problem. I've been
    wrestling with this for a long time and I know I have the above
    assembly correct. Any other ideas? It seems Microsoft knows how to
    make there controls appear in the toolbar. What can I do to make mine
    appear?
    Peter Kellner
    [url]http://peterkellner.net[/url]
    PeterKellner Guest

  7. #6

    Default Re: Composite control not appearing in toolbar...

    You can always add the manually.

    Brennan Stehling
    [url]http://brennan.offwhite.net/blog/[/url]

    PeterKellner wrote:
    > On 9 Oct 2006 13:16:22 -0700, "Brennan Stehling" <offwhite@gmail.com>
    > wrote:
    >
    > >Be sure you have your namespace set properly in the AssemblyInfo.
    > >
    > >[assembly: TagPrefix("CustomNamespace.Controls", "cnc")]
    > >
    > >It should match up with your controls.
    > >
    >
    > Hi,
    >
    > I just installed beta1 and still have the same problem. I've been
    > wrestling with this for a long time and I know I have the above
    > assembly correct. Any other ideas? It seems Microsoft knows how to
    > make there controls appear in the toolbar. What can I do to make mine
    > appear?
    > Peter Kellner
    > [url]http://peterkellner.net[/url]
    Brennan Stehling Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139