[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

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

Harper Trow

12/14/2007 10: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?

Thanks,
3 Answers

Nathan Sokalski

1/8/2008 3:07:00 AM

0

What exactly did you add to the web.config file?
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansok...

"Harper Trow" <HarperTrow@discussions.microsoft.com> wrote in message
news:A6795E05-4781-4787-B0A9-A64FDACD7FC5@microsoft.com...
>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,


Harper Trow

1/8/2008 3:21:00 PM

0

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

"Nathan Sokalski" wrote:

> What exactly did you add to the web.config file?
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansok...
>
> "Harper Trow" <HarperTrow@discussions.microsoft.com> wrote in message
> news:A6795E05-4781-4787-B0A9-A64FDACD7FC5@microsoft.com...
> >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,
>
>
>

Nathan Sokalski

1/8/2008 8:07:00 PM

0

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.nathansok...

"Harper Trow" <HarperTrow@discussions.microsoft.com> wrote in message
news:1F4A9F2C-253E-4BA8-97B6-FC159499AB6B@microsoft.com...
> <pages>
> <controls>
> <add tagPrefix="uc" src="~/topmenu.ascx" tagName="topmenu"/>
> </controls>
> </pages>
>
> "Nathan Sokalski" wrote:
>
>> What exactly did you add to the web.config file?
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansok...
>>
>> "Harper Trow" <HarperTrow@discussions.microsoft.com> wrote in message
>> news:A6795E05-4781-4787-B0A9-A64FDACD7FC5@microsoft.com...
>> >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,
>>
>>
>>