Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / June 2005

Tip: Looking for answers? Try searching our database.

Referencing a control outside of a user control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony Hedge - 15 Jun 2005 16:49 GMT
Hello,
I'd like to reference a control in a user control that is not in the user
control.  For esample, if I had the following in my .aspx:

...
<html>
 <form ID="frmMain"....>
   ...
   <asp:Label ID="lblMessage" ...>...</asp:Label>
   <uc:MyUserControl ID="ucTest"...></uc:MyUserControl>
   ...
 </form>
</html>
...

In any code behind routine of my user control ucTest I'd like to set:
         lblMessage.Text = "Hello"

But the user control doesn't 'see' the label.  I can write an algorithm/code
to cycle through all page controls to get the reference of the control I
want, but is there an easier way?
Much oblige - Hedge :-)
CT - 17 Jun 2005 09:08 GMT
Have you tried accessing the User Controls Parent control and that way gain
access to the label?

Signature

Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF
http://www.apress.com/book/bookDisplay.html?bID=105

> Hello,
> I'd like to reference a control in a user control that is not in the user
[quoted text clipped - 19 lines]
> want, but is there an easier way?
> Much oblige - Hedge :-)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.