473,395 Members | 1,675 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.

Access user control from other user control

Hello,

I have two UserControls on a aspx page. I need to read a property of the
first UserControl from within the second UserControl. The UserControls
only know about themselves, so I can't declare a variable of the other
usercontrol's type. So I can't do something like this in the second
UserControl:

FirstUserControl first =
(FirstUserControl)this.Parent.FindControl("FirstUs erControl")

Additionally I don't like to use the FindControl method, because it
returns an Object.

What's the best way to get to a usercontrol's properties from within an
other user control?

Greetings,
Chris


*** Sent via Developersdex http://www.developersdex.com ***
Feb 20 '08 #1
2 1550
In the first user control, you can declare a property of the type matching
the second user control and set this property from the page containing both
controls.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Chris Zopers" <te***********@12move.nlwrote in message
news:OX**************@TK2MSFTNGP03.phx.gbl...
Hello,

I have two UserControls on a aspx page. I need to read a property of the
first UserControl from within the second UserControl. The UserControls
only know about themselves, so I can't declare a variable of the other
usercontrol's type. So I can't do something like this in the second
UserControl:

FirstUserControl first =
(FirstUserControl)this.Parent.FindControl("FirstUs erControl")

Additionally I don't like to use the FindControl method, because it
returns an Object.

What's the best way to get to a usercontrol's properties from within an
other user control?

Greetings,
Chris


*** Sent via Developersdex http://www.developersdex.com ***

Feb 21 '08 #2
How would you go about doing this? Could you post an example?

I have one user control declared as "public partial class
controls_SecondaryDisabilities : System.Web.UI.UserControl" on a page
with a second user control declared as "
public partial class controls_StateList : System.Web.UI.UserControl".

I need to get a value from the second user control (the StateList) into
a variable in the first (the SecondaryDisabilities). The value is a
public string, so it is accessible. However, when I declare "protected
controls_StateList ddlPartState;", the controls_StateList is not being
found.

Thank you in advance.

*** Sent via Developersdex http://www.developersdex.com ***
Aug 5 '08 #3

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

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
5
by: jqpdev | last post by:
Hello all... I'm coming from a Borland Delphi background. Delphi has a specific component called a Data Module. In the designer the Data Module behaves like a windows form. A developer can...
5
by: djscratchnsniffing | last post by:
i know you can access an ascx's properties/methods from an aspx file. Let's say you have an aspx file with two code-behind files(ascx files). Can you access one of the ascx file's...
34
by: Mathieu Trentesaux | last post by:
Hello I downloaded Office 2007 for this reason : It seems, once again, that it is impossible to save any modification done in a VBA library, from the main project in Access. The save button...
37
by: Allen Browne | last post by:
If you develop for others, you probably have multiple versions of Access installed so you can edit and create MDEs for clients in different versions. This works fine under Windows XP, even with...
1
by: =?Utf-8?B?SlA=?= | last post by:
I have a default.aspx page. Default.aspx has placeholders. ASCX user controls are loaded into these placeholders at Page_Load. Each user control has a MultiView, within that there are two views...
16
by: Ben Sehara | last post by:
Is there any way I can limit the access to my website? I have a site "A" and I want to allow access to it only from site "B" login user. If someone try to access site "A" directory, I want it...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Thank you for that. It was very...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.