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

Access ASCX properties/methods from another ASCX file

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 properties/methods from the other
ascx file?

Nov 19 '05 #1
5 3025
<dj****************@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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 properties/methods from the other
ascx file?


You could, if the other .ascx file knew that the first one was there. But
why should it know that the other one is there?

You should try to make your user controls independant of each other, so that
they can be used in various combinations. You should allow the page that the
user controls are on to mediate between them (this is similar to the
Mediator Pattern). Have the user controls expose properties and events. The
page can set and read the properties, and can respond to the events.
Certainly, the page could set a property in one control based on the value
of a property in another control.

This way, each user control just does its own thing, and coordination for a
particular purpose is performed by the page.

The only exception to this is when you have a set of user controls which are
frequently used together to perform the same task. The solution is to create
a user control to contain this set of user controls. Let the container user
control be the Mediator of the controls it contains. The container might
have properties and events which were originally the properties and events
of its contained controls, but that's just fine:

Container.ascx.vb:

Protected WithEvents _innerControlA As InnerControlA

Public Property Username As String
Get
Return _innerControlA.Username
End Get
Set(ByVal Value As String)
_innerControlA.Username = Value
End Set
End Property

This way, the individual user controls in the Container are still
independant of each other, and one won't have to be changed if the other
changes. Only the Container would have to change, and the Page itself might
not even have to change.

John Saunders
Nov 19 '05 #2
dj****************@yahoo.com wrote:
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 properties/methods from the other
ascx file?

I don't see why not if you have a reference to the instances of classes in
the files
Nov 19 '05 #3
Sent an event or grab an interface:
http://www.openmymind.net/communication/index.html

S. L.

<dj****************@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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 properties/methods from the other
ascx file?

Nov 19 '05 #4

thanks for all of the help. i'll read the tutorial information. im sure
that will help.
im new to asp.net development. most of the stuff ive done is in asp.
i guess what im trying to do have a main aspx page with a few ascx
files (code-behind). Ascx A is where the user enters information. Ascx
B displays the results based upon the info entered into ascx A.
thanks again for the good leads. any assistance is always appreciated.

Nov 19 '05 #5

thanks for all of the help. i'll read the tutorial information. im sure
that will help.
im new to asp.net development. most of the stuff ive done is in asp.
i guess what im trying to do have a main aspx page with a few ascx
files (code-behind). Ascx A is where the user enters information. Ascx
B displays the results based upon the info entered into ascx A.
thanks again for the good leads. any assistance is always appreciated.

Nov 19 '05 #6

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

Similar topics

7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
2
by: adiel | last post by:
Hello, I am trying to access the properties and methods from a user control within the code-behind file for a webform but I am receiving the message: Name 'MenuBar1' is not declared It does...
2
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2...
6
by: William Parker | last post by:
I have a web control I made called header.ascx. It has its own properties and methods I defined. But I cannot figure out how to access this control from my code behind page. I can create the...
3
by: Mick | last post by:
Hi, Dragging & Dropping my ascx control in my aspx page, I just wanna know how I can access its properties when validating the form ? The control is composed of 4 controls (2 txtbox and 2 dropdown...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
5
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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...

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.