[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

Adding ascx control to Composite Control.

My page contains a composite control and I am trying to add 'ascx' control to this composite control, which will eventually rendered on the page.

I normally load any ascx control as loadControl ("`/path/XXX.ascx")
but in my composite control I cant get loadControl() method.

any help will be greatly appreciated.
0
Merion
Asked:
Merion
  • 2
2 Solutions
 
jinalCommented:
At Last your composite control is put into page. so inside composite control use

Control c = Page.LoadControl(""); then add to composite control.

0
 
jinalCommented:
This is look like this .  This is just sample.

public class Class1 : System.Web.UI.WebControls.CompositeControl 
{
	public Class1()
	{
		
	}
    protected override void CreateChildControls()
    {
        base.CreateChildControls();
        Control c = Page.LoadControl("~/mycontrol.ascx");
        c.ID = "MyControl";
        this.Controls.Add(c);
    }
}

Open in new window

0
 
MerionAuthor Commented:
Thanks for the reply.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now