how can I reference a user control from a page class?

H

Harper Trow

I am trying to reference a user control from a custom page class that all of
my other pages inherit from. Since the base page class is just a class file
with no aspx partial, I cannot use a @Register directive to register the user
control with the page class. I tried adding the user control to the
web.config so that all pages have access without the @Register directive, but
this did not allow me to reference the user control class name in my page
class, only pages with aspx UI partials. Is there any way to reference a
user control in a custom page class?

Thanks,
 
H

Harper Trow

<pages>
<controls>
<add tagPrefix="uc" src="~/topmenu.ascx" tagName="topmenu"/>
</controls>
</pages>
 
N

Nathan Sokalski

I can't remember exactly what the reason for the problem was, but when I
first started using UserControls, I had a problem. Somebody eventually told
me to place them in a separate directory, and that fixed my problem. See if
it helps by using the following:

<add tagPrefix="uc" src="~/usercontrols/topmenu.ascx" tagName="topmenu"/>
 

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,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top