Personalizing Using Web Parts->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:
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
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
Developer can create connection via code.
This example show how to Connect web Part using code.
Developer can disable connection point at runtime.
This example show how to disable connection point at runtime.
- 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.
- 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.
- Type text on the user control and click the button. the text that you typed should display on the Text Display Web Part
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
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
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
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


浙公网安备 33010602011771号