Problem with composite control

Discussion in 'ASP .Net' started by Mark Goldin, Aug 15, 2004.

  1. Mark Goldin

    Mark Goldin Guest

    I am trying to create my first composite control.

    Here is the code:

    using System;

    using System.Collections;

    using System.ComponentModel;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    namespace CompositeControls

    {

    [ToolboxData("<{0}:LabelMaskEdit runat=server></{0}:InteractiveSearchBox>")]

    public class LabelMaskEdit : Table, INamingContainer

    {

    protected Label LabelName = new Label();

    protected Infragistics.WebUI.WebDataInput.WebMaskEdit SearchTextBox = new
    Infragistics.WebUI.WebDataInput.WebMaskEdit();


    }

    }

    After I complied the control I can add it to Toolbar with no problem but
    when I add the control from Toolbar to aspx page I see a box with "Error
    creating control ..."

    Can someone help, please?
     
    Mark Goldin, Aug 15, 2004
    #1
    1. Advertising

  2. Hi Mark,

    If you move the cursor over the error message you should get a tooltip with
    a more specific error message, please post that message to help the guessing
    game.

    Also note that children controls of a composite control should always be
    created in an overriden CreateChildControls methods and not when declaring
    the fields as you are doing.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx
    My profile: http://aspnet2.com/mvp.ashx?vga


    "Mark Goldin" <> wrote in message
    news:%...
    > I am trying to create my first composite control.
    >
    > Here is the code:
    >
    > using System;
    >
    > using System.Collections;
    >
    > using System.ComponentModel;
    >
    > using System.Web.UI;
    >
    > using System.Web.UI.WebControls;
    >
    > namespace CompositeControls
    >
    > {
    >
    > [ToolboxData("<{0}:LabelMaskEdit

    runat=server></{0}:InteractiveSearchBox>")]
    >
    > public class LabelMaskEdit : Table, INamingContainer
    >
    > {
    >
    > protected Label LabelName = new Label();
    >
    > protected Infragistics.WebUI.WebDataInput.WebMaskEdit SearchTextBox = new
    > Infragistics.WebUI.WebDataInput.WebMaskEdit();
    >
    >
    > }
    >
    > }
    >
    > After I complied the control I can add it to Toolbar with no problem but
    > when I add the control from Toolbar to aspx page I see a box with "Error
    > creating control ..."
    >
    > Can someone help, please?
    >
    >
    >
    >
     
    Victor Garcia Aprea [MVP], Aug 15, 2004
    #2
    1. Advertising

  3. Mark Goldin

    Mark Goldin Guest

    I have this code now:
    using System;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.ComponentModel;

    using Infragistics.WebUI.WebDataInput;

    namespace WebControlLib

    {

    /// <summary>

    /// Summary description for WebCustomControl1.

    /// </summary>

    [DefaultProperty("Text"),

    ToolboxData("<{0}:LabelMaskEdit runat=server></{0}:LabelMaskEdit>")]

    public class LabelMaskEdit : System.Web.UI.WebControls.WebControl

    {

    private Label label;

    private WebMaskEdit textBox;

    [Bindable(true), Category("Appearance"), DefaultValue("")]

    public string LabelText

    {

    get

    {

    EnsureChildControls();

    return label.Text;

    }

    set

    {

    EnsureChildControls();

    label.Text = value;

    }

    }

    [Bindable(true), Category("Appearance"), DefaultValue("")]

    public string Text

    {

    get

    {

    EnsureChildControls();

    return textBox.Text;

    }

    set

    {

    EnsureChildControls();

    textBox.Text = value;

    }

    }

    protected override void CreateChildControls()

    {

    label = new Label();

    this.Controls.Add(label);

    textBox = new WebMaskEdit();

    this.Controls.Add(textBox);

    }

    }

    }

    It does not give me an error when I drop it on a form.
    But I am not getting to much of my control either.
    All I see is a label that I cannot assign a text to.
    I dont see a text box at all.
    What I want is to see text box with all its properties in a property window.
    For a label just a text is fine.
    How can I do that?
    Also when I change something in my customcontrol do I need to remove it
    from the form and drop on it again? (Not what I would expect).

    Thanks much for help.





    "Victor Garcia Aprea [MVP]" <> wrote in message
    news:#...
    > Hi Mark,
    >
    > If you move the cursor over the error message you should get a tooltip

    with
    > a more specific error message, please post that message to help the

    guessing
    > game.
    >
    > Also note that children controls of a composite control should always be
    > created in an overriden CreateChildControls methods and not when declaring
    > the fields as you are doing.
    >
    > --
    > Victor Garcia Aprea
    > Microsoft MVP | ASP.NET
    > Looking for insights on ASP.NET? Read my blog:
    > http://obies.com/vga/blog.aspx
    > My profile: http://aspnet2.com/mvp.ashx?vga
    >
    >
    > "Mark Goldin" <> wrote in message
    > news:%...
    > > I am trying to create my first composite control.
    > >
    > > Here is the code:
    > >
    > > using System;
    > >
    > > using System.Collections;
    > >
    > > using System.ComponentModel;
    > >
    > > using System.Web.UI;
    > >
    > > using System.Web.UI.WebControls;
    > >
    > > namespace CompositeControls
    > >
    > > {
    > >
    > > [ToolboxData("<{0}:LabelMaskEdit

    > runat=server></{0}:InteractiveSearchBox>")]
    > >
    > > public class LabelMaskEdit : Table, INamingContainer
    > >
    > > {
    > >
    > > protected Label LabelName = new Label();
    > >
    > > protected Infragistics.WebUI.WebDataInput.WebMaskEdit SearchTextBox =

    new
    > > Infragistics.WebUI.WebDataInput.WebMaskEdit();
    > >
    > >
    > > }
    > >
    > > }
    > >
    > > After I complied the control I can add it to Toolbar with no problem but
    > > when I add the control from Toolbar to aspx page I see a box with "Error
    > > creating control ..."
    > >
    > > Can someone help, please?
    > >
    > >
    > >
    > >

    >
    >
     
    Mark Goldin, Aug 15, 2004
    #3
    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. Replies:
    0
    Views:
    747
  2. sleigh
    Replies:
    1
    Views:
    2,738
    sleigh
    Feb 12, 2004
  3. shapper
    Replies:
    6
    Views:
    979
    shapper
    Dec 26, 2007
  4. Chad
    Replies:
    0
    Views:
    254
  5. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    292
    Sundararajan
    Mar 11, 2005
Loading...

Share This Page