FindControl() on a UserControl

Discussion in 'ASP .Net Building Controls' started by Alex Maghen, May 12, 2007.

  1. Alex Maghen

    Alex Maghen Guest

    Hi. I have created a UserControl ("MyUC"). I've put a bunch of instances of
    that control on a Page ("Defaul.aspx"). The control works fine.

    Now, I want to be able to use "FindControl()" from within my Default.aspx as
    follows:

    MyUC C = (MyUC)this.FindControl("SomeID");

    When I try to run this, I get error:
    "The type or namespace name 'MyUC' could not be found (are you missing a
    using directive or an assembly reference?)"

    This error is on that "FindControl()" line. Also, in the actual VS editor,
    in the Default.aspx code, the references to the type "MyUC" *do* show up in
    green and seem to be recognized. But when I run it, I get this error.

    So what I'm confused about is, how do I refernce this new control type I've
    created ("MyUC").

    One more note: None of my files (the ASPX pages, MyUC.ascx, etc.) have
    namespaces. I just created the files from within VS. Is there some default
    namespace I have to use or something?

    Much appreciated!

    Alex
     
    Alex Maghen, May 12, 2007
    #1
    1. Advertisements

  2. Hi Alex,

    Regarding on this issue, I have also found your another cross post below:

    Subject: FindControl() on ASP.NET UserControl Objects
    Newsgroups: microsoft.public.dotnet.framework.aspnet

    Since some community members and I have updated you there, if you feel
    convenient, we can continue to discuss in that thread.

    Thanks for your posting!

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], May 14, 2007
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.