This is a migrated thread and some comments may be shown as answers.

How to make Custom Control includes two rad controls

1 Answer 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Numan
Top achievements
Rank 1
Numan asked on 09 Mar 2009, 03:02 PM
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
}

1 Answer, 1 is accepted

Sort by
0
Todd Anglin
Top achievements
Rank 2
answered on 27 Mar 2009, 05:35 AM
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
Tags
General Discussions
Asked by
Numan
Top achievements
Rank 1
Answers by
Todd Anglin
Top achievements
Rank 2
Share this question
or