1

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
  • Here's a clue: when something goes wrong, it's not the framework. When you've done all the research you can and you're 100% confident it's the framework, it's still not the framework. It's your code. Commented Feb 17, 2009 at 14:41

3 Answers 3

1

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"); 
Sign up to request clarification or add additional context in comments.

Comments

0

Try this :

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

placeholder1.Controls.Add(uc);

hope it helps !

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.