hehe, come on, you should override CreateChildControls and doDropDownList ddl = new DropDownList(); Controls.Add(ddl);by the way, it is very bad to output html this way, you should be using a usercontrol instead of a custom control
you really shouldn't put that much html in your code, but if you insist, try namespace ViewControl { [DefaultProperty("Text"), ToolboxData("<{0}:SaiChen runat=server></{0}:SaiChen>")] public class SaiChen: System.Web.UI.WebControls.WebControl { private string teamContry; TextBox tb = new TextBox(); DropDownList ddl = new DropDownList(); [Bindable(true), Category("Appearance"), DefaultValue("")] public string TeamContry { get { return teamContry; } set { teamContry = value; } } proteced override void CreateChildControls() { Controls.Add(tb); Controls.Add(ddl); } protected override void Render(HtmlTextWriter output) { base.Render(output); ..... //or btn.RenderControl(output); // ddl.RenderControl(output);
Controls.Add(ddl);by the way, it is very bad to output html this way, you should be using a usercontrol instead of a custom control
namespace ViewControl
{
[DefaultProperty("Text"),
ToolboxData("<{0}:SaiChen runat=server></{0}:SaiChen>")]
public class SaiChen: System.Web.UI.WebControls.WebControl
{ private string teamContry;
TextBox tb = new TextBox();
DropDownList ddl = new DropDownList(); [Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string TeamContry
{
get
{
return teamContry;
} set
{
teamContry = value;
}
} proteced override void CreateChildControls()
{
Controls.Add(tb);
Controls.Add(ddl);
}
protected override void Render(HtmlTextWriter output)
{
base.Render(output);
..... //or btn.RenderControl(output);
// ddl.RenderControl(output);