473,566 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1470
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 misunderstandin g 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*******@disc ussions.microso ft.comwrote in message
news:0A******** *************** ***********@mic rosoft.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 misunderstandin g 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*******@disc ussions.microso ft.comwrote in message
news:0A******** *************** ***********@mic rosoft.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
1929
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. The question: When I use MyUserCtrl in a form, I must, from the form, make reference to both classes, i.e. even to "MyBaseClass". Otherwise, it will...
6
11274
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" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
4
2434
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 MS. Virtually every bit of the site is encapsulated within user controls. The problem begins when you try to have user controls pass information...
1
2048
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 instance of an object." when I declare the first user control like this from within the second UC Public formStandard As PIC.FormStandar .......
1
2121
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 to programming, but I am new to ASP.NET and Web application design in general... loved the concept of user controls and dynamically adding them to a...
0
2434
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 control to the main ..aspx page. In an attempt to make it more clear on what I am talking about, here is the order of events in page life cycle (from...
7
3182
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 -- UC/ ----- Classic/
5
2097
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 created. I have a delegate / event that passes via EventArgs the appropriate info from the grid to the UserControl2. This works fine, except for now...
1
4009
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 wrong. I have simplified the problem with the following example: Using asp.net 2.0, I have a Master page template used on default.aspx. >From...
0
7584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6260
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.