Welcome
|
ASP.NET
|
Web Services
|
How Do I...?
|
Class Browser
| I want my samples in...
C#
VB
ASP.NET Quickstart Tutorials
Go To...
C# Corner
VB.NET Heaven
.NET Heaven
Longhorn Corner
Personalizing Using Web Parts
Introducing Web Part Controls
Creating Custom Web Parts
Editing Web Part Properties
Personalizing Web Parts
Connecting Web Parts
Adding Display Modes
Authorizing Web Parts
Back to ASP.NET Home
Connections Between Web Parts
Web parts are also capable of exchanging data between them, using web part connections. Using connections, you can have one web part provide one or more property values that can be used by other web parts on the page. Web part connections have the following elements:
An interface that defines the communications contract between two parts. The interface describes properties and methods available through the connection.
A web part that behaves as a connection provider. To specify a provider connection point, a web part needs to have a method that creates and returns an instance of the communications interface. This method should be marked with the
ConnectionProvider
attribute. By default, A single provider connection point can be used with multiple connection consumers.
A web part that behaves as a connection consumer. To specify a consumer connection point, a web part needs to have a method that takes an instance of the communications interface as a parameter. This method should be marked with the
ConnectionConsumer
attribute. By default, A single consumer connection point can only be used with one connection provider.
You can connect web parts statically when you build the page, or allow parts to be connected dynamically by the user. At runtime, web part connections are managed by the WebPartManager, as follows:
For each registered provider, the WebPartManager calls its provider connection point method.
The provider part return an instance of the communications interface.
For each consumer registered for this provider, the WebPartManager calls its consumer connection point method, passing an instance of the interface .
The consumer part calls properties and methods on the interface instance.
This example shows a connection between two web parts on the page. The part that displays text connects to the user control web part that allows text entry. The two parts exchange text through the ITextCommunication interface.
Type text on the user control and click the button. the text that you typed should display on the Text Display Web Part
C# Static Connection
A user can establish connections between web parts by using the ConnectionZone. These type of connections are called dynamic connections.
This example shows how to Connect web Part dynamically
Log in to the page.
Select "Connect" from the dropdown.
Click the dropdown arrow on the Text Display Web Part's Verb Menu, and select "Connect" from the menu. The ConnectionZone will now be visible.
Click on "Create a connection to a Provider" link
Select Super cool user control from the dropdown
Click connect
Type text on the user control and click the button. the text that you typed should display on the Text Display Web Part
C# Dynamic Connection
A Web Part can provide multiple connection point; as a result it can participate on multiple connections.
This example show how to Connect web Part dynamically
Log in to the page.
Select "Connect" from the dropdown.
Click the dropdown arrow on the Text Display Web Part's Verb Menu, and select "Connect" from the menu. The ConnectionZone will now be visible.
Click on "Create a connection to a Provider" link
Select Super cool user control from the dropdown
Click connect
Click on "Create a connection to a consumer" link
Select "Untitled" from the dropdown
Click connect
Type text on the user control and click the button. the text that you typed should display on the Text Display Web Part as well as the number of letters in the text
C# Multiple Connection Points
Developer can create connection via code.
This example show how to Connect web Part using code.
Click on "Connect Web Part" button
Type text on the user control and click the button. The text that you typed should display on the Text Display Web Part
Click on "Disconnect Web Part" button. The text that you typed should not be display on the Text Display Web Part
C# Connecting Web Parts using Code
Developer can disable connection point at runtime.
This example show how to disable connection point at runtime.
Click the "Disable" radio button. this will break the connection between web parts
Click the "enable" radio button. this will reestablish the connection between web parts
C# Disabling Connection Point
Hosted by MaximumASP
|
Found a broken link?
|
Contact Us
|
Terms and conditions
|
Privacy Policy
|
Advertise with us
� 2000 -
2008
Mindcracker LLC. All Rights Reserved