I have this code now:
using System;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Componen tModel;
using Infragistics.We bUI.WebDataInpu t;
namespace WebControlLib
{
/// <summary>
/// Summary description for WebCustomContro l1.
/// </summary>
[DefaultProperty ("Text"),
ToolboxData("<{ 0}:LabelMaskEdi t runat=server></{0}:LabelMaskEd it>")]
public class LabelMaskEdit : System.Web.UI.W ebControls.WebC ontrol
{
private Label label;
private WebMaskEdit textBox;
[Bindable(true), Category("Appea rance"), DefaultValue("" )]
public string LabelText
{
get
{
EnsureChildCont rols();
return label.Text;
}
set
{
EnsureChildCont rols();
label.Text = value;
}
}
[Bindable(true), Category("Appea rance"), DefaultValue("" )]
public string Text
{
get
{
EnsureChildCont rols();
return textBox.Text;
}
set
{
EnsureChildCont rols();
textBox.Text = value;
}
}
protected override void CreateChildCont rols()
{
label = new Label();
this.Controls.A dd(label);
textBox = new WebMaskEdit();
this.Controls.A dd(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]" <vg*@NOobiesSPA M.com> wrote in message
news:#z******** *****@TK2MSFTNG P11.phx.gbl...
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 CreateChildCont rols 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" <ma********@com cast.net> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. I am trying to create my first composite control.
Here is the code:
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Web.UI;
using System.Web.UI.W ebControls;
namespace CompositeContro ls
{
[ToolboxData("<{ 0}:LabelMaskEdi t
runat=server></{0}:Interactive SearchBox>")]
public class LabelMaskEdit : Table, INamingContaine r
{
protected Label LabelName = new Label();
protected Infragistics.We bUI.WebDataInpu t.WebMaskEdit SearchTextBox =
new Infragistics.We bUI.WebDataInpu t.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?