FindControl() on a UserControl

A

Alex Maghen

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
 
S

Steven Cheng[MSFT]

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.
 

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,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top