Programatically adding a user control through code

B

Ben Dewey

Everyone,

I am building a new ASP.NET App in 2.0. First off I love it, I can develop
things much quicker. One issue that I has been frustrating me alot is the
fact that I can't access the codebehind from other pages.

If I go to the object browser for my site the only objects are the ones that
I created in the App_Code Directory. I found a few work arounds before but
I can't seem to find one for my current issue.

I have a UserControl called ArticleTocControl.ascx, with a codebehind of
ArticleTocControl.ascx.cs, which loads the table of contents for a CNN type
atricle. I need to programmatically add create

ArticleTocControl toc = new ArticleTocControl();
Controls.Add(toc);

the problem is that I can't access the ArticleTocControl object.

Is there some kind of namespace tag, or <@ precompiler tag I can put on to
make the codebehind an accessable object?
 
B

bruce barker \(sqlwork.com\)

because the usercontrol is its own dll, you need to add a reference to it on
the page. see the @Reference directive.

-- bruce (sqlwork.com)
 
B

Ben Dewey

Is there anyway to do that through code.

The page that is going to use it is a BasePage Class.
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top