Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > FindControl() on a UserControl

Reply
Thread Tools

FindControl() on a UserControl

 
 
Alex Maghen
Guest
Posts: n/a
 
      05-12-2007
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
 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      05-14-2007
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting a property of a control inside a usercontrol, from another usercontrol Fabiano ASP .Net 2 06-03-2005 09:56 AM
accessing usercontrol from another usercontrol Phl ASP .Net 2 11-18-2004 07:33 PM
Access a control inside an usercontrol from another control inside another usercontrol nail ASP .Net 0 09-15-2004 03:55 PM
Can we use a usercontrol inside a usercontrol Rajesh Tiwari ASP .Net 0 08-12-2003 03:56 PM
Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack huobazi ASP .Net 1 07-03-2003 03:14 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57