<asp:textbox runat=server><asp:dropdownlist>应该没有这种控件吧?

解决方案 »

  1.   

    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
      

  2.   

    我也考虑过重载CreateChildControls 方法,可是这样布局不是很好控制!!!如果用CreateChildControls ,请问如何控制!!
      

  3.   

    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);