Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • 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

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

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