Dynamically Added User Control

J

Jenni.Haughton

I have a solution with 2 projects in it. I need to programatically
add a user control from one project into the other one (as you cannot
declare this normally on the form because it is in a different
application). When the page_load event of the user control is fired at
run-time, none of the form objects on the user control exist.

Is this a namespace issue? Or can you just not share a user control
over 2 projects without having a copy in both projects.

Thanks,
Jenni
 
L

Lloyd Sheen

I have a solution with 2 projects in it. I need to programatically
add a user control from one project into the other one (as you cannot
declare this normally on the form because it is in a different
application). When the page_load event of the user control is fired at
run-time, none of the form objects on the user control exist.

Is this a namespace issue? Or can you just not share a user control
over 2 projects without having a copy in both projects.

Thanks,
Jenni

This should be easy. I would create a third project for the usercontrol.
Then from each of the other projects either reference the usercontrol
assembly or the usercontrol project depending on the level of debugging you
are doing. Then when the usercontrol has changes the other two projects
will automatically pick up the new version (if you open the projects and
build the project).

Hope this helps,
Lloyd Sheen
 
J

Jenni.Haughton

Thanks for the post.
The trouble is accessing the user control once it is in a seperate
project. I can reference it ok, but at run-time the control within
the user control do not exist.

Thanks,
Jen
 
L

Lloyd Sheen

Thanks for the post.
The trouble is accessing the user control once it is in a seperate
project. I can reference it ok, but at run-time the control within
the user control do not exist.

Thanks,
Jen
Do you mean that you have multiple controls within your usercontrol?

If so you must provide the method of accessing the controls. This can be
done with functions or readonly properties.

Hope this helps
Lloyd Sheen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top