Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding ascx control to Composite Control.

Posted on 2009-07-15
3
Medium Priority
?
429 Views
Last Modified: 2013-11-07
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
Comment
Question by:Merion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
jinal earned 1500 total points
ID: 24861065
At Last your composite control is put into page. so inside composite control use

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

0
 
LVL 15

Assisted Solution

by:jinal
jinal earned 1500 total points
ID: 24861073
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
 

Author Comment

by:Merion
ID: 24861185
Thanks for the reply.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question