Next, we add a new method to the CustomerListWebPart called ProvideICustomerID that
returns an ICustomerID object. The new method is decorated with the ConnectionProvider
attribute so that the web part infrastructure is aware of how to connect this web part.
For the CustomerInvoicesWebPart, we add a private variable called customerIDProvider
of type ICustomerID to hold a reference. We also add a GetICustomerID method that takes a
parameter of type ICustomerID and assigns it to the private variable customerIDProvider. Finally,
we override OnPreRender for the CustomerInvoicesWebPart so that the CustomerID can be retrieved
from the provider and set on the CustomerInvoicesWebPart??™s CustomerID property.
Wiring Up the Page
To allow connections between the web parts, we first add a ConnectionZone web control to the
CustomerInfoWebPart.aspx markup and add verbs such as connect, configure, disconnect, and
so on to the ConnectionZone control. We also override OnPreRender in CustomerInfoWebPart.
aspx.cs and set properties for the connection verbs and UI to customize the connection functionality.
This completes the work necessary to wire up our server controls and link them the
web-part way.
464 CHAPTER 10 ?– OTHER SERVER CONTROLS
To test this functionality, run the page, and select the new Connect option that appears
as a Display mode.
Pages:
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596