473,748 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3050
<dj************ ****@yahoo.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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******** *************@f 14g2000cwb.goog legroups.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
8867
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 want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
11
6598
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 where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
2
13732
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 not recognize the user control in the code behind... Here is the code for the user control: MenuBar.ascx:
2
3023
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 or more user controls dynamically by adding to a placeholder defined in page_load. I've included the sample code for how we are accessing one. The user controls are not rocket science - just a few text boxes with public accessor properties. We've...
6
535
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 web control just fine and script with it as needed from the webform1.aspx page itself just fine, like this: <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="mysite.WebForm1" %> <%@ Register TagPrefix="uc1"...
3
12387
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 : Address, ZipCode, Country & City). In fact, when, in my code, I try "this.MyControlId".... it does not exist. Thks for help.
2
1978
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 submit. I've read several post here and articles on the web on this topic. What little I have learned from them is that you have to pre-compile the usercontrol in order to access it in the aspx code behind. I did this, compiling the usercontrol...
5
2688
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 that's come before. To take an extreme example, suppose you have been writing Visual Basic applications for years now. If you're like many developers, you will have built up a substantial inventory of code in that time. And if you've been following...
3
6441
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 BarLabelText. I now have a contentpage "FooBar.aspx", where "Bar.master" is the master page and in the content section has the control "Foo.ascx".
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9321
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4602
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.