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

How to communicate between users controls in web form?

How to pass messages through events from a user control to its containing
page, or to another user control? Is there any recommended way? Thanks very
much.

Jun 27 '08 #1
6 4671
Hi,

As for asp.net

Declare a event in the user control and then fire the event on your
purpose...
subscribe the event of the user control..... in page... you can also
declare
your custom delegate for this purpose...

Okay now... the above solution will serve your purpose yet you can do
lot of engineering in this issue...
you can also implement observer pattern...

its your choice

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com

Jun 27 '08 #2
from user control, u can access the page by just calling "Page"
property
to access other controls, try Page.FindControls("")

If Page doesn't work, try Parent
On Jun 24, 9:47*am, "Simon" <Sim...@nospam.nospamwrote:
How to pass messages through events from a user control to its containing
page, or to another user control? Is there any recommended way? Thanks very
much.
Jun 27 '08 #3
Hi Simon,

From your description, what you want to do is let the usercontrol and its
container page or other user control on the same page communicate or share
some data with each other , correct?

As for the communication, would you provide some further details about what
process will a typical communication between them followup? Generally,
since the UserControl has the "Page" property, I think you can try define
some custom properties on the Page class and then let the usercontrol get
reference to its container page, and set those custom properties to forward
certain data(from user control to page).

If you want to share data between different usercontrol instance, I think
it is necessary to perform FindControl from page. For example, one
usercontrol first get reference to its container page, and then search for
another usercontrol on the page(and access properties on that usercontrol).
However, FindControl require you to know the control hierarchy/structure
on the page.

Anyway, please feel free to let me know if you have further particular
requirements or concerns here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Reply-To: "Simon" <Si****@nospam.nospam>
From: "Simon" <Si****@nospam.nospam>
Subject: How to communicate between users controls in web form?
Date: Tue, 24 Jun 2008 09:47:30 +0800
>
How to pass messages through events from a user control to its containing
page, or to another user control? Is there any recommended way? Thanks
very
>much.

Jun 27 '08 #4
Thanks very much. I think I could begin from findcontrol method and then
exchange some data among user controls.
"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:Jl**************@TK2MSFTNGHUB02.phx.gbl...
Hi Simon,

From your description, what you want to do is let the usercontrol and its
container page or other user control on the same page communicate or share
some data with each other , correct?

As for the communication, would you provide some further details about
what
process will a typical communication between them followup? Generally,
since the UserControl has the "Page" property, I think you can try define
some custom properties on the Page class and then let the usercontrol get
reference to its container page, and set those custom properties to
forward
certain data(from user control to page).

If you want to share data between different usercontrol instance, I think
it is necessary to perform FindControl from page. For example, one
usercontrol first get reference to its container page, and then search for
another usercontrol on the page(and access properties on that
usercontrol).
However, FindControl require you to know the control hierarchy/structure
on the page.

Anyway, please feel free to let me know if you have further particular
requirements or concerns here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>Reply-To: "Simon" <Si****@nospam.nospam>
From: "Simon" <Si****@nospam.nospam>
Subject: How to communicate between users controls in web form?
Date: Tue, 24 Jun 2008 09:47:30 +0800
>>
How to pass messages through events from a user control to its containing
page, or to another user control? Is there any recommended way? Thanks
very
>>much.

Jun 27 '08 #5
Thanks for your quick reply Simon,

Also, for "FindControl" method, I'd like to inform you to take care of the
control/structure. For example, the FindControl method can only search
controls in the same NamingContainer context. In other words, if two user
controls are put inside the same naming container, you can use the
following code to find control :

UserControl1.NamingContainer.FindControl("Usercont rol2")

here is a web article mentioned functionality of FindControl method:

http://aspadvice.com/blogs/joteke/ar.../12/20546.aspx

If you encounter any further problem, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

--------------------
>Reply-To: "Simon" <Si****@nospam.nospam>
>Subject: Re: How to communicate between users controls in web form?
Date: Tue, 24 Jun 2008 15:36:27 +0800
mework.aspnet:70268
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Thanks very much. I think I could begin from findcontrol method and then
exchange some data among user controls.
"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:Jl**************@TK2MSFTNGHUB02.phx.gbl...
>Hi Simon,

From your description, what you want to do is let the usercontrol and its
container page or other user control on the same page communicate or
share
>some data with each other , correct?

As for the communication, would you provide some further details about
what
process will a typical communication between them followup? Generally,
since the UserControl has the "Page" property, I think you can try define
some custom properties on the Page class and then let the usercontrol get
reference to its container page, and set those custom properties to
forward
certain data(from user control to page).

If you want to share data between different usercontrol instance, I think
it is necessary to perform FindControl from page. For example, one
usercontrol first get reference to its container page, and then search
for
>another usercontrol on the page(and access properties on that
usercontrol).
However, FindControl require you to know the control hierarchy/structure
on the page.

Anyway, please feel free to let me know if you have further particular
requirements or concerns here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Jun 27 '08 #6
Got it. Thanks, Steven for your useful help. :)

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:An**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your quick reply Simon,

Also, for "FindControl" method, I'd like to inform you to take care of the
control/structure. For example, the FindControl method can only search
controls in the same NamingContainer context. In other words, if two user
controls are put inside the same naming container, you can use the
following code to find control :

UserControl1.NamingContainer.FindControl("Usercont rol2")

here is a web article mentioned functionality of FindControl method:

http://aspadvice.com/blogs/joteke/ar.../12/20546.aspx

If you encounter any further problem, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

--------------------
>>Reply-To: "Simon" <Si****@nospam.nospam>
>>Subject: Re: How to communicate between users controls in web form?
Date: Tue, 24 Jun 2008 15:36:27 +0800
mework.aspnet:70268
>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Thanks very much. I think I could begin from findcontrol method and then
exchange some data among user controls.
"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:Jl**************@TK2MSFTNGHUB02.phx.gbl.. .
>>Hi Simon,

From your description, what you want to do is let the usercontrol and
its
container page or other user control on the same page communicate or
share
>>some data with each other , correct?

As for the communication, would you provide some further details about
what
process will a typical communication between them followup? Generally,
since the UserControl has the "Page" property, I think you can try
define
some custom properties on the Page class and then let the usercontrol
get
reference to its container page, and set those custom properties to
forward
certain data(from user control to page).

If you want to share data between different usercontrol instance, I
think
it is necessary to perform FindControl from page. For example, one
usercontrol first get reference to its container page, and then search
for
>>another usercontrol on the page(and access properties on that
usercontrol).
However, FindControl require you to know the control hierarchy/structure
on the page.

Anyway, please feel free to let me know if you have further particular
requirements or concerns here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Jun 27 '08 #7

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

Similar topics

30
by: Blnukem | last post by:
Hi All I'm new to javascript and was wondering if someone can help me with this I want to disable my second and third drop-box if the first one is selected to "Closed" I think I'm close but just...
1
by: bscofield | last post by:
Hi, I'm a db app. developer and I am re-writing some helps in javascript & HTML. The Javascript is for form flow and design and HTML just to display the helps. I use a seperate app. development...
3
by: Douglas Macnguyen | last post by:
I have multiple user controls (.ascx) on a page (.aspx). How can a user control interact with each other? Also, how can a user control interact with the page? TIA, Douglas
0
by: Steve Teeples | last post by:
Hi. Can someone tell me the proper way to communicate between controls on a form? I have two TreeView controls (each on a separate panel). I'd like to copy a node (by double clicking the mouse)...
0
by: Craig Buchanan | last post by:
I have two user controls. The first is a form with a few buttons and fields. It is embedded in the Item template of a repeater that is on the second user control. I would like to send...
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
4
by: Eric Sabine | last post by:
For a certain app, I'd like the user to be able to move buttons around (I mean physically move them). The reason isn't really important, but it has to do with an organizational layout. Anyway, it...
3
by: steve | last post by:
Hi I've been wondering for a wile now if its possible to make an application were the user can make a form by inputting data in variables this by using VB.net Example The user gets a dataset...
2
by: Kenneth Roy | last post by:
I have an application using a grid control. I have set up user settings for each column of the grid to enable the user to determine various properties of those columns. For example whether a...
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:
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...
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...

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.