473,320 Members | 1,580 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,320 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 1695
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.