473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Programatically adding a user control through code

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?
May 5 '06 #1
2 1250
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)
"Ben Dewey" <As*********@hotmail.com> wrote in message
news:uc**************@TK2MSFTNGP04.phx.gbl...
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?

May 5 '06 #2
Is there anyway to do that through code.

The page that is going to use it is a BasePage Class.
May 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andrea Williams | last post by:
Does anyone know of some in depth documentation regarding how to add user controls programatically? I have a User Control, which has some basic html controls, and depending on the number selected...
1
by: francois | last post by:
Hi, I would like to add a USER control (not custom control) programmatically to my aspx page. I am using something like the following in my page_load code : * Bos.UserControls.HeaderFinance...
4
by: stb | last post by:
I have an empty asp:table on a form. Rows and cells in the rows are added programatically. At the end of each row, there is a cell with a button inside it. How do I catch the button's click...
1
by: Khadim | last post by:
greetings, i am trying to develop an application which is supposed to show pdf. i have added the activeX control from the acrobat in my application. everything was working fine, until i got to...
11
by: Neo Geshel | last post by:
Greetings. Hopefully someone will be able to untie this Gordian Knot I have found myself bound up in. I am trying to add a submit button dynamically to a PlaceHolder. This button will help...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.