By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,507 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,507 IT Pros & Developers. It's quick & easy.

User control referencing

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.