all groups > asp.net building controls > may 2005 >
You're in the

asp.net building controls

group:

acces controls on aspx page from user control


acces controls on aspx page from user control fabrice
5/25/2005 12:00:00 AM
asp.net building controls:
Hello,

I'm trying to access a Label Control on my .aspx page from a User Control.
But I don't manage it.
Do somebody help me to do that ?

My aspx is mypage.aspx
a control label in it :

<asp:Label id="myLabel" runat="server"></asp:Label>



In ascx :
How to fix the Text property of the label ID=mylabel.


thanks a lot.

fabrice

Re: acces controls on aspx page from user control Brock Allen
5/25/2005 10:39:21 AM
You can use FindControl("YourControlID"), but IMO it's a bit odd (and perhaps
indicative of a flawed design) to have a user control make an assumption
about the presence of a Control elsewhere on the page.

-Brock
DevelopMentor
http://staff.develop.com/ballen



[quoted text, click to view]


Re: acces controls on aspx page from user control MasterGaurav
5/25/2005 10:40:12 PM
If the UserControl is under your control (at design time), I would
suggest that "myLabel" is made public.

That's the best way to go about it.


--
Cheers,
Gaurav Vaish
http://mastergaurav.blogspot.com
http://mastergaurav.org
-------------------
AddThis Social Bookmark Button