473,424 Members | 1,708 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,424 software developers and data experts.

passing same property to multiple controls

OK, due to peer pressure, I'm caving into the concept that one should have
the ASPX page TELL the ascx pages what's going on rather than vice versa.
;o)

I have an aspx page that needs to pass a property to the usercontrols it's
loading (some dynamically via codebehind).

I can certainly just pass the property as such:

<control:control1 property="myProperty" />
<control:control2 property="myProperty" />
<control:control3 property="myProperty" />
<control:control4 property="myProperty" />

Not a huge deal, but I was wondering if there was a way to pass the same
property to all controls at once programmitically just to simplify things a
tad. Something like allControlsOnThisPage.myProperty = "whatever"

I imagine I could first search for all controls, set that as an array, then
loop through each one to set all the properties. But, in the end, that seems
like more processing than it's worth.

-Darrel
Nov 19 '05 #1
8 976
What I did was add a property to the page that copies the value to the user
controls sort of hierarchically. I also had to keep track of the user
controls in array too, but for that one ugly method, it helped keep
everything else neat.
Nov 19 '05 #2
> What I did was add a property to the page that copies the value to the
user
controls sort of hierarchically. I also had to keep track of the user
controls in array too, but for that one ugly method, it helped keep
everything else neat.


OK, so I could then load the page, scan through the aspx page to grab all of
the controls, then assign the value to them.

In terms of performance, is this overkill?

-Darrel
Nov 19 '05 #3
"darrel" <no*****@hotmail.com> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
What I did was add a property to the page that copies the value to the

user
controls sort of hierarchically. I also had to keep track of the user
controls in array too, but for that one ugly method, it helped keep
everything else neat.


OK, so I could then load the page, scan through the aspx page to grab all
of
the controls, then assign the value to them.

In terms of performance, is this overkill?


How many such controls do you have? If you've only got 10 or so, then this
isn't overkill, it's laziness.

John Saunders
Nov 19 '05 #4
> How many such controls do you have? If you've only got 10 or so, then this
isn't overkill, it's laziness.


Doing the array is laziness? Or declaring the properties one by one manually
in the code is laziness?

My eventual goal is to make this fairly easy for someone else to update
without adding unecessary performance hits.

So, if I leave, and someone needs a new 'site' made, they can just copy the
ASPX page, and then change the parameters for the controls in an easy as
possible way. I thought setting it once would be the way to go, but perhaps
that's just not a practical thing to do in .net?

-Darrel
Nov 19 '05 #5
"darrel" <no*****@hotmail.com> wrote in message
news:e0**************@TK2MSFTNGP15.phx.gbl...
How many such controls do you have? If you've only got 10 or so, then
this
isn't overkill, it's laziness.


Doing the array is laziness? Or declaring the properties one by one
manually
in the code is laziness?

My eventual goal is to make this fairly easy for someone else to update
without adding unecessary performance hits.

So, if I leave, and someone needs a new 'site' made, they can just copy
the
ASPX page, and then change the parameters for the controls in an easy as
possible way. I thought setting it once would be the way to go, but
perhaps
that's just not a practical thing to do in .net?


Darrel,

One idea I gave you in an earlier post was that all of these controls should
derive from the same base class. This would avoid duplication of code. It
would then be possible to recursively search the page for all controls which
derive from this base class. For each of the located controls, you could set
the property, since it would be a property of that base class.

John Saunders
Nov 19 '05 #6
> One idea I gave you in an earlier post was that all of these controls
should
derive from the same base class. This would avoid duplication of code. It
would then be possible to recursively search the page for all controls which derive from this base class. For each of the located controls, you could set the property, since it would be a property of that base class.


Could I not do that without the need to derive from a base class as well?
(Ie, find all controls on the page, recursively go through them to set the
property)?

Deriving controls from a base class is where my lack of understanding OOP
concepts begins to show a bit. ;o)

I'll do some reading on that. Thanks John!

-Darrel
Nov 19 '05 #7
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
One idea I gave you in an earlier post was that all of these controls

should
derive from the same base class. This would avoid duplication of code. It
would then be possible to recursively search the page for all controls

which
derive from this base class. For each of the located controls, you could

set
the property, since it would be a property of that base class.


Could I not do that without the need to derive from a base class as well?
(Ie, find all controls on the page, recursively go through them to set the
property)?

Deriving controls from a base class is where my lack of understanding OOP
concepts begins to show a bit. ;o)

I'll do some reading on that. Thanks John!


How would you set the property, Darrel?

John Saunders
Nov 19 '05 #8
> How would you set the property, Darrel?

I was thinking you'd get each property ID, and then just start setting them:

projectClass.controlID.property = "whatever"

I don't know. I'm kind of lost on this whole concept of passing variables
between pages and controls. I know I'm not supposed to be thinking in terms
of pages and that's what's throwing me off.

For now, I'm just going to manually set all of these properties and be done
with it, and once this project is underway, hopefully find some time to sit
back and absorb some books on the higher-level .net stuff focussing on the
OOP stuff.

I appreciate all the help/advice you've given!

-Darrel
Nov 19 '05 #9

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

Similar topics

1
by: Prosonman | last post by:
Hi, What is the best way to transfer variables to and from a dialog box? My project consists of a form with a number of controls, lets say three Labels, when a label is clicked it opens a dialog...
4
by: Darrel | last post by:
I'm really stuck on the concept of using public variables to pass information between usercontrols. I'm pretty sure I'm just flubbing up the syntax. This is what I want: page usercontrol 1 -...
3
by: voro.cibus | last post by:
I have been reading up on this all day, and I can't find the answer (or more likely, don't understand the answers I have found) to my problem. I have a table that stores the name of my ascx page....
6
by: RBCC | last post by:
Public Class fraction Dim m_numerator As Int16 Dim m_denominator As Int16 Public Event zerodenom() Public Property numerator() As Int16 Get Return m_numerator
0
by: Eric Sabine | last post by:
OK, I'm trying to further my understanding of threading. The code below I wrote as kind of a primer to myself and maybe a template that I could use in the future. What I tried to do was pass data...
3
by: Gary Kahrau | last post by:
I hope this is a simple question. I have a number of usercontrols placed on a form. The usercontrol has a public property (DispMachine) within it. When looping through the main form controls, I...
12
by: scottt | last post by:
hi, I am having a little problem passing in reference of my calling class (in my ..exe)into a DLL. Both programs are C# and what I am trying to do is pass a reference to my one class into a DLL...
13
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On...
1
by: SteveDouglas | last post by:
Hi all, I am currently writing an application in VB.NET that has a lot of controls (treeviews/listviews/labels and so forth) that represent "things" that need to be draggable from place to place,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.