简体   繁体   中英

Server control in server control ASP.NET

I'm trying to learn how to make server controls for asp.net. I use DevExpress which are 3rd party server controls. I'm trying to add a DevExpress button to my server control.

public class Class1 : CompositeControl
{
    private DevExpress.Web.ASPxEditors.ASPxButton btnTest;

    protected override void Render(HtmlTextWriter writer)
    {            
        btnTest.RenderControl(writer);
    }

    protected override void CreateChildControls()
    {
        btnTest = new DevExpress.Web.ASPxEditors.ASPxButton();
        btnTest.Text = "wazzzup"; 
        Controls.Add(btnTest);
    }
}

For some reason the button will not show up in the design view unless there is another devexpress control on the same page as my server control. Any idea how to fix this?

由于您是从CompositeControl继承的,因此您不应覆盖Render。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM