Site is of type ISite, which is an interface that derives from the IServiceProvider interface.
IServiceProvider has a GetService method that permits the server control to gain access to
design-time services, as described in Table 11-1. In our code, we get two services, one of type
IDesignerHost and the other of type IComponentChangeService.
IDesignerHost is used to add and retrieve services available in the design-time environment
and handle events related to designer state. IDesignerHost provides support for detecting a
558 CHAPTER 11 ?– DESIGN-TIME SU PPORT
designer is loading and managing component and designer transactions. We use IDesignerHost to
wrap component editing into a transaction of type DesignerTransaction.
IComponentChangeService permits a designer to receive notifications when components are
changed, added, or removed from the design-time environment. We use IComponentChangeService
to notify the hosting environment??”in this case, Visual Studio??”that the component is being
edited. Note that this code will cause Visual Studio to want to check out the .aspx page for
editing if the .aspx page is under source control:
changeSrvc.OnComponentChanging( (TitledThumbnail)component, null);
Once EditComponent initiates the DesignerTransaction and notifies Visual Studio that the
page is about to be edited, it displays the TitledThumbnailComponentEditorDlg Windows Form.
Pages:
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731