Class of UserControl not found in Page

Discussion in 'ASP .Net' started by Mathias Fritsch, Mar 28, 2008.

  1. 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
     
    Mathias Fritsch, Mar 28, 2008
    #1
    1. Advertising

  2. Mathias Fritsch

    Alex Meleta Guest

    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>
     
    Alex Meleta, Mar 28, 2008
    #2
    1. Advertising

  3. Mathias Fritsch

    bruce barker Guest

    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)


    "Mathias Fritsch" wrote:

    > 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
    >
     
    bruce barker, Mar 28, 2008
    #3

  4. >
    > 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")
     
    Mathias Fritsch, Mar 30, 2008
    #4
  5. 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.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Mathias Fritsch" <> wrote in message
    news:...
    >
    >>
    >> 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")
    >
    >
    >
     
    Juan T. Llibre, Mar 30, 2008
    #5
  6. Thank you all: I added <%@ Reference Control="YourUserControl.ascx"
    %> and things are compiling now!

    Mathias
     
    Mathias Fritsch, Apr 3, 2008
    #6
  7. Good news, Mathias !



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Mathias Fritsch" <> wrote in message
    news:...
    > Thank you all: I added <%@ Reference Control="YourUserControl.ascx"
    > %> and things are compiling now!
    >
    > Mathias
     
    Juan T. Llibre, Apr 3, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. huobazi
    Replies:
    1
    Views:
    700
    David Waz...
    Jul 3, 2003
  2. Replies:
    0
    Views:
    484
  3. Event not firing in usercontrol inside usercontrol

    , Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    189
  4. Event not firing in usercontrol inside usercontrol

    , Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    191
    vatech1993
    Dec 11, 2004
  5. Event not firing in usercontrol inside usercontrol

    , Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    161
Loading...

Share This Page