473,395 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Referencing a control outside of a user control

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 :-)
Jul 21 '05 #1
1 1698
CT
Have you tried accessing the User Controls Parent control and that way gain
access to the label?

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

"Tony Hedge" <To*******@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
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 :-)

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Milind | last post by:
Hi, I was trying to implement a composition relation, somthing of the following type: class A { public: class B {
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
by: Tony Hedge | last post by:
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...
3
by: gary | last post by:
Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is located in a "/include" folder If you have a...
1
by: Israel | last post by:
The problem: I want to know, definitively when a slider loses focus after a user has started sliding and hasn't released the mouse yet. It appears that this is captured with the WM_ACTIVATEAPP...
3
by: tshad | last post by:
I am trying to put together a user control (.ascx). Can you access an outside control from it? My control: login2.ascx ****************************************************************...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
2
by: Sin Jeong-hun | last post by:
If I create a button like control, then I simply can draw button-like lines on my User Control's surface by getting its Graphics g. If I draw outside of the control's ClientRectangle (for example,...
2
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
Hi all I have a user control - mycontrol.ascx with various controls within it. mycontrol.ascx is utilised in myPage.aspx I have a class (class1) to carry out various functions, subs etc. How...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.