Class of UserControl not found in Page

M

Mathias Fritsch

I am using FindControl in my page and try to cast the control found to
a specific control.

((Controls_Footer)this.Master.FindControl("Footer1")).OnPrintToPdf +=
new Controls_Footer.PrintToPdf(Footer1_OnPrintToPdf);

This works but after a while doesnt compile anymore in Visual Studio.

"Type Controls_Footer not found" is the error.

I can then change the web.config to compile in release and it compiles
again - well most of the time.

It compiles without problems on my buildserver which uses a
webdeployment - project.

What is wrong here?

Mathias
 
A

Alex Meleta

Hi Mathias,

Where is the file conained the class 'Contols_Footer' located?

Regards,
Alex Meleta
[Tech Blog: http://devkids.blogspot.com]

MF> I am using FindControl in my page and try to cast the control found
MF> to a specific control.
MF>
MF> ((Controls_Footer)this.Master.FindControl("Footer1")).OnPrintToPdf
MF> += new Controls_Footer.PrintToPdf(Footer1_OnPrintToPdf);
MF>
MF> This works but after a while doesnt compile anymore in Visual
MF> Studio.
MF>
MF> "Type Controls_Footer not found" is the error.
MF>
MF> I can then change the web.config to compile in release and it
MF> compiles again - well most of the time.
MF>
MF> It compiles without problems on my buildserver which uses a
MF> webdeployment - project.
MF>
MF> What is wrong here?
MF>
MF> Mathias
MF>
 
B

bruce barker

you a counting on compile batching (compiling pages into one dll) to resolve
reference. you can select rebuild or as you shoudl have done in the forst
place, add a reference to the in page

-- bruce (sqlwork.com)
 
M

Mathias Fritsch

Where is the file conained the class 'Contols_Footer' located?
Alex,
All files are contained in one web. MasterPage and aspx-Page are in
the main folder.

Controls_Footer is located in subfolder called: Controls.

All files use the same namespace: B2BShop.Web.
The aspx and ascx files have a reference which uses the namespace in
the Inherit - Attribute.
(Inherits="B2BShop.Web.Controls_ProductDetail")
 
J

Juan T. Llibre

re:
!> Controls_Footer is located in subfolder called: Controls.

re:
!> The aspx and ascx files have a reference which uses the namespace in
!> the Inherit - Attribute. (Inherits="B2BShop.Web.Controls_ProductDetail")

Another way to do this is by placing the .ascx file in the App_Code directory.

See:
http://odetocode.com/Blogs/scott/archive/2005/10/01/2293.aspx

....you don't even need a reference, although the ascx source must use inline code.
That isn't practical for you if you use codebehind in the ascx ( some.ascx.cs, for example ).

However, Bruce is right.

If you want to do it the way you're currently doing it, you must include a reference :

<%@ Reference Control="YourUserControl.ascx" %>

The Inherits statement doesn't provide a reference.
 
M

Mathias Fritsch

Thank you all: I added <%@ Reference Control="YourUserControl.ascx"
%> and things are compiling now!

Mathias
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top