473,408 Members | 2,832 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,408 software developers and data experts.

User control referencing

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 do I go about setting the properties of the controls within
mycontrol.ascx directly from class1

Ideally what i'd like to do is various control property settings in class1
when the myPage.aspx page load event fires - but for various reasons I don't
want this done in the code behind of myPage.aspx or myControl.ascx -
(myControl.ascx will be utilised across the site and the various controls
within it will need their properties set depending on certain conditions that
may arise)

This sort of control referencing was very easy in access adp but I'm a bit
bit lost here!!

Any pointers - vb.net (if possible)

Thanks

Sep 19 '08 #1
2 1461
Thanks Richard

How would i go about your suggestions? Do you have any examples?
"Richard Coltrane" wrote:
Hi James,

Not sure where your difficulty lies with this.

A user control is just a class, so if u want to set its properties from
another class, simply send a reference to it, to that class and make sure it
exposes its controls as public properties..... or design some interface to
allow this to be done.

Better yet though i would go the other way. Send a class with the property
values to the User Control and allow the usercontrol to set its own
properties. Even if you have to design a third class to act as a property
container i would still do it this way. Much cleaner.

Perhaps im misunderstanding but id never send a UserControl to code class to
have it propertes set. i.e. send presention tier into business logic tier
for configuration. Yuk.

hth
"James Page" <Ja*******@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...
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 do I go about setting the properties of the controls within
mycontrol.ascx directly from class1

Ideally what i'd like to do is various control property settings in class1
when the myPage.aspx page load event fires - but for various reasons I
don't
want this done in the code behind of myPage.aspx or myControl.ascx -
(myControl.ascx will be utilised across the site and the various controls
within it will need their properties set depending on certain conditions
that
may arise)

This sort of control referencing was very easy in access adp but I'm a bit
bit lost here!!

Any pointers - vb.net (if possible)

Thanks


Sep 20 '08 #2
Thanks again Richard

Found exactly what I needed to know at MSDN specifically at:

http://msdn.microsoft.com/en-us/libr...ercontrol.aspx

Its all very clear now!

"Richard Coltrane" wrote:
Hi James,

Not sure where your difficulty lies with this.

A user control is just a class, so if u want to set its properties from
another class, simply send a reference to it, to that class and make sure it
exposes its controls as public properties..... or design some interface to
allow this to be done.

Better yet though i would go the other way. Send a class with the property
values to the User Control and allow the usercontrol to set its own
properties. Even if you have to design a third class to act as a property
container i would still do it this way. Much cleaner.

Perhaps im misunderstanding but id never send a UserControl to code class to
have it propertes set. i.e. send presention tier into business logic tier
for configuration. Yuk.

hth
"James Page" <Ja*******@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...
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 do I go about setting the properties of the controls within
mycontrol.ascx directly from class1

Ideally what i'd like to do is various control property settings in class1
when the myPage.aspx page load event fires - but for various reasons I
don't
want this done in the code behind of myPage.aspx or myControl.ascx -
(myControl.ascx will be utilised across the site and the various controls
within it will need their properties set depending on certain conditions
that
may arise)

This sort of control referencing was very easy in access adp but I'm a bit
bit lost here!!

Any pointers - vb.net (if possible)

Thanks


Sep 20 '08 #3

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

Similar topics

1
by: M Shafaat | last post by:
Hi! I have made a user control called, say "MyUserCtrl", which is inherited from another user defined class called, say "MyBaseClass". Each one of these two are developed in its own project. ...
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"...
4
by: Josh Harris | last post by:
Here is my question: It is common to have many pieces of business logic encapsulated within asp.net user controls. This can be found in high visibility projects such as the iBuySpy portal from...
1
by: abjork | last post by:
I have a aspx page with two user controls. One of them holds some properties that I would like to set from the other user control. How do I do that I keep getting "Object reference not set to an...
1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
0
by: ab_j | last post by:
I have a user control that contains a dropdown which I want to use as a menu on multiple .aspx pages. Basically, all I am trying to do is pass the selected value of the dropdown in the user...
7
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
5
by: Doug Handler | last post by:
Hi, I have a form (Form1) that contains a tab control which one tab has a customer user control (UserControl1). When the user double-clicks on the grid hosted there a new user control is...
1
by: yoknows | last post by:
Hello .Net Gurus. This is my first post here so I apologize in advance if I have not provided the right information. I hope someone has seen this problem before and can tell me what I am doing...
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?
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...

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.