G
Griff
Hi - I'm just experimenting and following the example in:
http://msdn2.microsoft.com/en-us/library/ms379565.aspx
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();
}
}
}
http://msdn2.microsoft.com/en-us/library/ms379565.aspx
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();
}
}
}