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

  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. 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:
    717
    David Waz...
    Jul 3, 2003
  2. Rajesh Tiwari

    Can we use a usercontrol inside a usercontrol

    Rajesh Tiwari, Aug 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    435
    Rajesh Tiwari
    Aug 12, 2003
  3. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    FindControl() on ASP.NET UserControl Objects

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 13, 2007, in forum: ASP .Net
    Replies:
    14
    Views:
    978
    Steven Cheng[MSFT]
    May 24, 2007
  4. Bill E.
    Replies:
    5
    Views:
    1,407
    Bill E.
    Jan 8, 2010
  5. theComputer7
    Replies:
    5
    Views:
    1,382
    theComputer7 - no spam
    Jun 24, 2004
Loading...

Share This Page