Groups | Blog | Home
all groups > asp.net building controls > december 2007 >

asp.net building controls : how can I reference a user control from a page class?


Harper Trow
12/14/2007 2:04:00 PM
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?

Nathan Sokalski
1/7/2008 10:07:24 PM
What exactly did you add to the web.config file?
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

[quoted text, click to view]

Harper Trow
1/8/2008 7:21:01 AM
<pages>
<controls>
<add tagPrefix="uc" src="~/topmenu.ascx" tagName="topmenu"/>
</controls>
</pages>

[quoted text, click to view]
Nathan Sokalski
1/8/2008 3:07:06 PM
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"/>
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

[quoted text, click to view]

AddThis Social Bookmark Button