views:

771

answers:

3

I am trying to create a instance of a user web control from the code behind of another user web control.

using ASP.NET;

 placeholder1.Controls.Clear();
            module_userWebControl_ascx slModule = (module_userWebControl_ascx)LoadControl("~/module/module_userWebControl.ascx");
            placeholder1.Controls.Add(slModule);

Are there issues with the 2.0 framework?

error: The type or namespace name'module_userWebControl_ascx could not be found (are you missing a using directive or a assembly reference?)

**Please add namespaces or references to solution. Other solutions don't contain namespaces and I don't have the reputation to add comments yet.

+1  A: 

I looks like the page you are placing that code does not belong to the same namespace of the usercontrol.

try:

(usercontrolNamespace.module_userWebControl_ascx)LoadControl("~/module/module_userWebControl.ascx");
Sergio
A: 

Try this :

UserControl uc = new UserControl();
uc.LoadControl(Server.MapPath("module/userWebControl.ascx"));

placeholder1.Controls.Add(uc);

hope it helps !

Canavar
A: 

Add <%@ Reference Control="~/module/module_userWebControl.ascx" %> to your parent control's ascx

LicenseQ