How to use a web user control from one web app in another web app?

I have a production web app project (at work) that has custom web user controls in it.

I have another web app project for experimenting and I want to use some web controls from the production web app. The big trick is that I need to load the controls dynamically.

LoadControl() doesn't seem to work - it complains about loading controls from a different application. I also tried adding a project reference to the production web app and using "UC1 newUC = new UC1();" and then "this.Controls.Add(newUC);", but the controls (like TextBoxes) on the web user control don't seem to exist on the new UC1s.

If it would help, I can probably quickly hack together a sample similar to my work project and post all code for review.

Any and all advice appreciated!

Thanks in advance,
Andrew
0
AndrewJMarshall
7/2/2005 1:32:01 AM
📁 asp.net.web-forms
📃 93655 articles.
⭐ 6 followers.

💬 2 Replies
👁️‍🗨️ 1415 Views

What you may need to explore here, is how to make Custom Controls using .Net. It's fairly easy when you have the right tools, like VS.Net, but not rocket science difficult without it either. If you often find yourself needing a certain Pattern of different Controls used in a certain context, creating a Custom Controls out of these will often simplify your work tremendously. A custom Control consisting of different Controls grouped together like this is called a Composite Control. Create the Control, inheriting from most suitable Class (e.g. the Webcontrol or Control Class), add your own Properties, Method, Delegates and Events to your Control, compile the Code and add it to your ToolBox (if you're using VS.Net), and you're good to go. If you know nothing about making Custom Controls, visit this link;

http://aspalliance.com/345


It's a great primer for anybody who wants to build their own Controls.
Regards

Andre Colbiornsen
---------------------------------
Seventh Day
Råbygatan 1A,
SE-223 61 Lund
Sweden
Mob.: +46-(0)708-97 78 79
Mail: [email protected]
--------------------------------
0
adec
7/2/2005 1:55:55 AM
Terribly sorry, I seem to have scanned your post a bit too fast. To be able to use the Custom Controls like you want, you need to get hold of the Assembly containing the compiled Code for the Control/s. In your case I would probably include the Assembly in your application's /Bin folder 'using' the Control's Namespace in the Pages where you intend to include the Control/s.

If the Control/s  will be used extensively, you should consider registering the Assembly in the GAC (Global Assembly Cache) of both your Development Machine and your Production Server (if possible).
Regards

Andre Colbiornsen
---------------------------------
Seventh Day
Råbygatan 1A,
SE-223 61 Lund
Sweden
Mob.: +46-(0)708-97 78 79
Mail: [email protected]
--------------------------------
0
adec
7/2/2005 2:07:21 AM
Reply: