Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem with composite control

Reply
Thread Tools

Problem with composite control

 
 
Mark Goldin
Guest
Posts: n/a
 
      08-15-2004
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?




 
Reply With Quote
 
 
 
 
Victor Garcia Aprea [MVP]
Guest
Posts: n/a
 
      08-15-2004
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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?
>
>
>
>



 
Reply With Quote
 
 
 
 
Mark Goldin
Guest
Posts: n/a
 
      08-15-2004
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]" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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?
> >
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Composite vs non composite Controls Mike ASP .Net Web Controls 4 03-11-2005 05:47 AM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM
Composite control with dynamic composite controls sleigh ASP .Net 1 02-12-2004 06:24 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net 0 07-01-2003 09:26 PM



Advertisments