How to make Custom Control includes two rad controls

2 posts, 0 answers
  1. Numan
    Numan avatar
    2 posts
    Member since:
    Jan 2009

    Posted 09 Mar 2009 Link to this post

    Hi,

    I want to create a custom control. This control will be derived from any rad controls. And i want to create a new control in overrided render method. When i try in the following example I'm getting this error: "Script control 'blabla' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
    Parameter name: scriptControl"


    Do you have any idea or any example?

    Example:

    //Using my custom control in aspx file
    ....//any codes
    <mcc:MyCustomControl ID="mcc1" runat="server" />
    ....//any codes

    //My Custom Control Class
    public class MycustomControl : RadTextBox
    {
    ....//any codes
            protected override void Render(HtmlTextWriter writer)
            {
                      RadGrid customControlGrid = new RadGrid();
                      customControlGrid.ID = "blabla";
                      customControlGrid.Page = this.Page;
                      customControlGrid.......
                      customControlGrid.RenderControl(writer);
                      base.Render(writer);
            }
    ....//any codes
    }

  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 27 Mar 2009 Link to this post

    Hello Numan-

    If you'd like to create a custom control that has multiple RadControls, your best bet is probably to inherit from CompositeControl instead of directly from RadTextBox. This approach will make it much easier to add controls, configure their properties, and render them predictably- and it will eliminate the errors you're currently encountering. For some help creating CompostieControls, check out these tutorials:

    http://www.codersource.net/published/view/288/creating_composite_control_in_asp_net.aspx
    http://www.bbits.co.uk/blog/archive/2005/10/20/4904.aspx

    Hope that helps!
    -Todd
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top