7/28/2019 2435110.pdf
1/160
Lab Resource Toolkit
7/28/2019 2435110.pdf
2/160
Information in this document, including URL and other Internet Web site references, is subject to
change without notice. Unless otherwise noted, the example companies, organizations, products,domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious,
and no association with any real company, organization, product, domain name, e-mail address,
logo, person, place or event is intended or should be inferred. Complying with all applicable
copyright laws is the responsibility of the user. Without limiting the rights under copyright, nopart of this document may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or
otherwise), or for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you anylicense to these patents, trademarks, copyrights, or other intellectual property.
2004 Microsoft Corporation. All rights reserved.
Microsoft, MS-DOS, Windows, Windows NT, Windows Server, FrontPage, SharePoint, Visual
Basic, Visual Studio, and Windows Media are either registered trademarks or trademarks ofMicrosoft Corporation in the United States and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of theirrespective owners.
Workshop: 2014B
Released: 03/2004
7/28/2019 2435110.pdf
3/160
Lab Resource Toolkit iii
Table of Contents
Unit 2: Adding Web Parts to Web Part Pages.................................................................................1 Reference: Adding Web Parts to a Web Part Page....................................................................................1
Reference: Setting Web Part Properties ....................................................................................................3How To: Add Web Parts to Web Part Pages.............................................................................................4How To: Set the Properties for a Web Part ...............................................................................................5Unit 3: Using Web Part Templates in Visual Studio.NET 6.0.........................................................6How To: Install the Web Part Template Package......................................................................................6How To: Create a Simple Web Part Library Project .................................................................................7Unit 4: Web Parts as ASP.NET Custom Controls...........................................................................8How To: Create Web Part Classes ............................................................................................................8How To: Add Child Controls to Web Parts.............................................................................................13How To: Render the HTML for a Web Part............................................................................................26How To: Create and Display Custom Properties.....................................................................................39
How To: Implement Event Handlers.......................................................................................................44How To: Implement Control Event Handler ...........................................................................................62Unit 5: Connecting Web Parts........................................................................................................67Reference: Creating a Connectable Web Part .........................................................................................67Reference: ICellConsumer Interface .......................................................................................................71How To: Implement ICellConsumer Web Part .......................................................................................73Unit 6: Packaging and Deploying Web Parts..............................................................................121Reference: Example Manifest File ........................................................................................................121Reference: Nodes and Subnodes used in the Manifest File for a .CAB File.........................................122How To: Create the .dwp file for the CustomerRowProvider Web Part ...............................................123How To: Create the .dwp file for the OrdersCellConsumer Web Part ..................................................124
How To: Modify the Manifest.xml file .................................................................................................125How To: Move the XML Data Files to the Project Directory ...............................................................126How To: Build a Web Part Package......................................................................................................127How To: Add a Web Part Package........................................................................................................128How To: Delete a Web Part Package ....................................................................................................129How To: Enumerate Web Part Packages...............................................................................................130How To: Add Web Parts to Web Part Pages.........................................................................................131Unit 7: Web Part Security in IIS 6.0..............................................................................................132Reference: Code Access Security..........................................................................................................132Reference: Code Access Security Basics ..............................................................................................133Reference: Creating Your Own Code Access Permissions ...................................................................134
Reference: FileIOPermissionAccess Enumeration................................................................................135Reference: Introduction to Code Access Security.................................................................................137Reference: Specific Permissions Granted By Windows SharePoint Services Custom Policy Files .....139
Reference: Using Libraries from Partially Trusted Code......................................................................140Reference: Writing Secure Class Libraries ...........................................................................................141Reference: Writing Secure Managed Controls......................................................................................142How To: Create a Strongly Named Assembly ......................................................................................144How To: Install a Web Part ...................................................................................................................147
7/28/2019 2435110.pdf
4/160
iv Lab Resource Toolkit
Unit 8: Exploring the Windows SharePoint Services Object Model .........................................150Reference: Programmability in Microsoft Windows SharePoint Services............................................150How To: Create a SharePoint Web Application....................................................................................151How To: Set a Reference to the Windows SharePoint Services Assembly...........................................152How To: Enumerate a SharePoint Server List.......................................................................................153
7/28/2019 2435110.pdf
5/160
Lab Resource Toolkit 1
Unit 2: Adding Web Parts to Web Part PagesThe following sections contain the information from the Resources tab in the LabToolkit for thisunit.
Reference: Adding Web Parts to a Web Part PageMicrosoft Windows SharePoint Services provides four types of galleries that can contain WebParts:
Virtual Server Gallery
Gallery
Web Part Page Gallery
Online Gallery
The Virtual Server Gallery lists Web Parts that are available to all sites on the server. The Gallery contains Web Parts that are available to a particular site. By default, whenyou run Stsadm.exe to install a Web Part, Stsadm.exe adds the Web Part to the Virtual ServerGallery. More information about how to work with the administration tools available in WindowsSharePoint Services to populate the Web Site gallery is available later in this article.
A Web Part Page gallery contains Web Parts that are already added to the current page. This mayseem paradoxical at first. Why would you need to add a Web Part that is already added to the page?The reason this is useful is that you can add a Web Part to a page and then close the Web Part. Toclose a Web Part, click the arrowhead on the right side of the Web Part title bar, and then clickClose. A closed Web Part is no longer visible on the page, but it is still a member of the Web PartPage gallery for that page. The Web Part is still associated with the page by an entry in theconfiguration database of the server running Windows SharePoint Services, which also stores anyshared or personalized property settings for the Web Part.
You can add a Web Part to a page, personalize it extensively, close it, and then later add it back tothe page with the personalization intact. To bring back a closed Web Part, select it from the WebPart Page gallery.
Note: To truly delete a Web Part from a page, you must click the Modify My Page menu (orthe Modify Shared Page menu in shared view), and then click Design this Page to add theDelete command to the drop-down menu of the Web Part. To remove the Web Part from the
page without adding it to the Web Part Page gallery, click the arrowhead on the right side ofthe Web Part title bar, and then click Delete.
The online gallery is a set of Web Parts that are available over a Web service. This permits manyservers to share access to a common, centrally maintained gallery of Web Parts. The URL for this
Web service is specified in the OnlineLibrary element of the Web.config file for a site.
Important To enable the online gallery, you must edit the Web.config file on the server andchange the URL attribute of the OnlineLibrary element to the following:
7/28/2019 2435110.pdf
6/160
2 Lab Resource Toolkit
Important If you use a proxy server, you must also add the following section:
Figure 1 shows the sample CustomerCellConsumer Web Part being dragged onto a page from theVirtual Server gallery. This is the gallery where the sample Web Parts are installed when you usethe Stsadm.exe tool, as described earlier in this article.
Figure 1. Adding a Web Part to a page in Internet Explorer
Drag-and-drop operations for adding Web Parts to a page are available in browsers that support richuser interaction. However, Web Parts do not require Microsoft Internet Explorer or even a browserthat supports dynamic HTML. That is one reason that the task pane shown in Figure 1 includes adrop-down list for choosing a Web Part Zone on the page and an Add button for adding the
selected Web Part to the selected zone. Additionally, these alternative controls make Web Partsaccessible to users who do not use a mouse.
Note Several of the figures in this article show screenshots of Web Parts on the home page fora site. You are not limited to adding Web Parts to the home page for a site. To create a newWeb Part page, click Create in the menu bar, scroll to the bottom of the Create Page page tothe Web Pages heading, and then click Web Part Pages. On the New Web Part Page page, youcan name the new page, you can select a page layout from a list, and you can select thedocument library to contain the new page. You can then add Web Parts to the new page.
7/28/2019 2435110.pdf
7/160
Lab Resource Toolkit 3
Reference: Setting Web Part PropertiesWeb Parts share common properties, such as Title, Height and AllowClose. The Zone that a WebPart appears in is also a property of the Web Part. You can add custom properties to your Web Parts
by adding standard .NET properties to the class for the Web Part.
When you set Web Part properties in the browser, the scope of the modification depends on
whether the page is in Personal view or Shared view. Changes made in Personal view apply only tothe current user and take precedence over changes made in Shared view. Use Shared view to setdefault values for all users of that page.
To change the properties for a Web Part, click the arrowhead on the right side of the Web Parttitlebar, and then clickModify My Web Part (in Personal view) orModify Shared Web Part (inShared view). You do not need to switch the page to Design view to make this selection. However,the page automatically changes to Design view when the task pane for setting properties appears. InDesign view, you see an outline around each Web Part Zone and a title for the zone.
The sample CustomerRowProvider Web Part has a custom Boolean property, DetailViewEnabled,which determines how much information about the selected customer is displayed in the Web Part.Figure 2 shows how the property appears in a task pane in the browser.
Figure 2. Setting a custom property in Internet Explorer
Attributes in the C# code for the property provide the custom View category for this property and
the friendly name and tool tip that appears in the task pane. The Web Part infrastructureautomatically creates a check box control for the property because it has a Boolean data type.
7/28/2019 2435110.pdf
8/160
4 Lab Resource Toolkit
How To: Add Web Parts to Web Part Pages
Tasks Supporting information
1. On the Dublin virtual
computer, navigate to the
Northwind Sales team
site.
a. Log the Dublin virtual computer on to DUBLIN (this computer) with a
user name ofAdministrator and a password ofP@ssw0rd.
b. ClickStart, point to All Programs, and then clickInternet Explorer.
c. Select the In the future, do not display this message check box if the
following error dialog displays: Microsoft Internet Explorers
Enhanced Security Configuration is currently enabled on your
server.
d. In the Address box, type http://dublin and then clickGo.
e. When the dialog box appears to connect to Dublin, log on as
Administrator with a password ofP@ssw0rd.
f. ClickSites on the navigation bar.
g. ClickSales in the Newest Sites list.
Note: As an alternate way to navigate to the Sales team site, you can type
http://dublin/sites/Sales/default.aspx in the Internet ExplorerAddress field,
and then clickGo.When the dialog box appears to connect to Sales site, log
on as Administrator with a password ofP@ssw0rd.
2. Add a Contacts web part
to the Northwind Sales
team site to enable Sales
personal to easily find
information about other
team members.
a. Verify that the Web Part page is in Shared View:
Click the Modify My Page menu. If the Shared View icon is
highlighted, the page is in shared view (default view). If the page is
in Personal View, clickShared View.
Note:To add a Web Part only to your personal view, click the Modify
Shared Page menu, then clickPersonal View.
b. Search for the Contacts Web Part. ClickModify Shared Page link, point to Add Web Parts, and then
clickBrowse.
Note: By clicking Browse, you can select any of the four libraries to
view a list of the Web Parts in that gallery. However, if you click
Search, you can limit your selection to Web Parts with names that
contain your search text. Both the Browse command and the Search
command open a list of the four available libraries, with a number for
each gallery that shows how many Web Parts are available in that
gallery. When you select a gallery, a list of the Web Parts in that gallery
displays.
c. Add the Contacts Web Part to the Web Part page.
Verify that Sales Gallery is selected. If the Sales Gallery is not
highlighted, click it to display its Web Parts in the Web Parts List.
Drag the Contacts Web Part from the task pane into a Web Part zone
on the page.
3. Leave the Web Part Page
open and in its current
state.
Do notclick anything else on the browser or page because Exercise 2:
Setting Web Part Properties will continue from here.
7/28/2019 2435110.pdf
9/160
Lab Resource Toolkit 5
How To: Set the Properties for a Web Part
Tasks Supporting information
1. Open the properties task
pane for the Contacts
Web Part.
a. Verify that the Sales Web Part page is open, if the Sales page is not
open:
Open Internet Explorer.
Type http://dublin/sites/Sales/default.aspx in the Address field,
and then clickGo.
If you are required to logon again, type a user name of
Administrator and a password ofP@ssw0rd.
b. Verify the page is in Shared View.
Click the Modify My Page menu. If the Shared View icon is
highlighted, the page is in shared view (this is the default view). If
the page is in Personal View, clickShared View.
Note:To add a Web Part only to your personal view, click the Modify
Shared Page menu, then clickPersonal View.c. Open the properties task pane for the Contacts Web Part:
Click the drop-down arrow on Contacts Web Part title bar, and then
clickModify Shared Web Part. The Task pane opens to display the
Contacts Web Part properties. Notice the Contacts Web Part has a
dotted border around it indicate it is the active Web Part.
d. Change the title property for the Contacts Web Part:
Click the Appearance node to expand it, and then enterNorthwind
Sales Contacts in the Title field.
Click the Apply orOKbutton.
Note:If you wish,you may continue changing the properties of this Web
Part to see the effects on the Web Part page. Any changes you makewill notaffect any of the Lab exercises for the remainder of this
workshop.
2. Change the title of the
Web Part from Contacts
to Northwind Sales
Contacts.
a. Change the title property for the Contacts Web Part:
Click the Appearance node to expand it, delete the word Contacts
in the Title field, and then type Northwind Sales Contacts.
Click the Apply orOKbutton.
Note:If you wish,you may continue changing the properties of this Web
Part to see the effects on the Web Part page. Any changes you make
will notaffect any of the Lab exercises for the remainder of this
workshop.
b. Close Internet Explorer:
ClickX on the upper right-hand corner of the browser.
7/28/2019 2435110.pdf
10/160
6 Lab Resource Toolkit
Unit 3: Using Web Part Templates in Visual Studio.NET 6.0
The following sections contain the information from the Resources tab in the LabToolkit for thisunit.
How To: Install the Web Part Template Package
Tasks Supporting information
1. Open the Web Part Templates
for Microsoft Visual Studio
.NET.
a. ClickStart, clickMy Computer, navigate to the C:\Program
Files\Microsoft Learning\2014\Unit03\Resources folder and then
double-click the WebPartTemplatesforVSNetSample.EXE file.
b. Click the Yes button to accept the agreement.
c. Enter the location where you want to place the extracted files, such as
C:\WebPartTemplates. It is not essential to place the files in a specificfolder location.
d. ClickOK.
e. ClickOKin the Web Part Templates for Microsoft Visual Studio
.NET Sample window.
2. Install the Web Part
Templates.
a. Double-click the Setup.Exe file to install the package.
Note:If a security alert appears, choose to trust content only if the
source of the file is Microsoft.
b. The Setup Wizard starts. ClickNext to install the package.
c. ClickI Agree in the License Agreement window, then clickNext.
d. Select the programming languages for the templates, then clickNext.Note:By default, the Setup Wizard installs C# Web Part Templates
and Microsoft Visual Basic Web Part Templates.
e. In the text box provided, type the location of the Windows SharePoint
Services assembly in the file system, then clickNext.
Note: If Windows SharePoint Services is installed on your machine,
the default location will already be populated in the text box (for
example, C:\Program Files\Common Files\Microsoft Shared\Web
Server Extensions\60\ISAPI\).
f. The Confirm Installation page appears. ClickNext to continue.
g. The templates begin to install. The Installation Completepage
appears. ClickClose to close the Setup Wizard.
7/28/2019 2435110.pdf
11/160
Lab Resource Toolkit 7
How To: Create a Simple Web Part Library Project
Tasks Supporting information
1. Open Visual Studio .NET. ClickStart, point to All Programs, point to Microsoft Visual
Studio .NET 2003, and clickMicrosoft Visual Studio. NET 2003.
2. Open a new project. a. On the File menu, point to New, and then clickProject.
b. Select eitherVisual Basic Projects orVisual C# Projects from the
Project Typesand then choose Web Part Library from the
Templates.
3. Save the project. Choose a location to save the project. Type Northwind in the Name
field, and then clickOK. The project has now been created with the
appropriate references.
7/28/2019 2435110.pdf
12/160
8 Lab Resource Toolkit
Unit 4: Web Parts as ASP.NET Custom ControlsThe following sections contain the information from the Resources tab in the LabToolkit for thisunit.
How To: Create Web Part ClassesInstructions
The answer keys for each exercise provide you with explicit supporting information designed tohelp you complete the lab. As you work through this exercise, you can verify your progress usingthe code snippets for each exercise task located in the C# and Visual Basic .NET Code Samplesections of this document. For example, to see the C# code for the second task, locate the C# CodeSample section titled, Exercise #1, Task #2 and compare this code to your own work.
To copy the code for an exercise task and paste it into your project, open:
C#:
C:\Program Files\Microsoft Learning\2014\Labfiles\Unit04\Resource\
CustomerRowProvider.cs.txt
Visual Basic .NET:
C:\Program Files\Microsoft Learning\2014\Labfiles\Unit04\Resource\CustomerRowProvider.vb.txt
To view the completed solution for this lab, open:
C#:
C:\Program Files\Microsoft Learning\2014\Labfiles\Unit04\CS\Solution\Northwind\Northwind.sln
Visual Basic .NET:
C:\Program Files\Microsoft Learning\2014\Labfiles\Unit04\VB\Solution\Northwind\Northwind.sln
7/28/2019 2435110.pdf
13/160
Lab Resource Toolkit 9
Tasks Supporting information
1. Open the Northwind project
in Microsoft Visual Studio
.NET.a. ClickStart, point to All Programs, point to Microsoft Visual
Studio .NET 2003, then clickMicrosoft Visual Studio. NET 2003.b. Open the Northwind project.
C#:
Open the Starter file:
C:\Program Files\Microsoft Learning\2014\Labfiles\
Unit04\CS\Starter\Northwind
Double-click the Northwind.sln file.
Add a reference to the System.Data namespace.
o Right-clickReferences in Solution Explorer
o Select Add Reference
o Highlight System.Data.dll
o
Click the Select buttono Click the OKbutton
Visual Basic:
Open the Starter file:C:\Program Files\Microsoft Learning\2014\Labfiles\Unit04\
VB\Starter\Northwind Double-click the Northwind.sln file.
2. Create the Customer Row
Provider Web Part.
a. Delete the Web Part file, and add a new class.
C#:
Delete WebPart1.cs in the Solution Explorer pane.
Right-click the Northwind project in the Solution Explorer pane,
point to Add, then clickAdd Class.
Select Provider Web Part in the Templates field.
Name the file CustomerRowProvider.cs in the Name field.
ClickOpen.
Visual Basic.NET:
Delete WebPart1.vb.
Right-click the Northwind project in the Solution Explorer pane,
point to Add, then clickAdd Class.
In the resulting dialog, select Provider Web Part.
Name the file CustomerRowProvider.vb
ClickOpen.
b. Define a class that:
Inherits from the WebPart class
(Microsoft.SharePoint.WebPartPages.WebPart).
Implements the IRowProvider communication interface.
c. Save the file.
Click the Save toolbar icon.
7/28/2019 2435110.pdf
14/160
10 Lab Resource Toolkit
Note When you open a new solution in Microsoft Visual Studio using the Web Part templatesyou will notice that some code is already included. In the code samples below, any code
provided by Microsoft Visual Studio Web Part templates is italicized.
For example, code included by Microsoft Visual Studio Web Part templates looks like:
using System;
Code that you will enter looks like:
[DefaultProperty("Text"),
7/28/2019 2435110.pdf
15/160
Lab Resource Toolkit 11
C# Code Samples
Exercise #1, Task #2
using System;
using System.Data;using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.InteropServices;
using Microsoft.SharePoint.WebPartPages;
// This reference provides the interfaces required for part
communication
using Microsoft.SharePoint.WebPartPages.Communication;
namespace Northwind
{///
/// Web Part server control for selecting a Northwind
customer
/// and displaying information about the selected
customer.
/// Implements the IRowProvider interface for WebPart
connections.
///
///
// The DefaultProperty and ToolboxData attributes
// are used by design environments like Visual Studio.
// XmlRoot is used for XML serialization.
[DefaultProperty("Text"),
ToolboxData(""),
XmlRoot(Namespace="Northwind")]
public class CustomerRowProvider : WebPart, IRowProvider
// Inherit from the WebPart base class and implement the
IRowProvider interface.
{
7/28/2019 2435110.pdf
16/160
12 Lab Resource Toolkit
VB .NET Code Samples
Exercise #1, Task #2
Imports System
Imports System.ComponentModelImports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports System.Runtime.InteropServices
Imports System.Security
Imports System.Security.Permissions
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.WebPartPages
Imports Microsoft.SharePoint.WebPartPages.Communication
' Web Part server control for selecting a Northwind customer
' and displaying information about the selected customer.' Implements the IRowProvider interface for WebPart
connections.
' The DefaultProperty and ToolboxData attributes
' are used by design environments like Visual Studio.
' XmlRoot is used for XML serialization.
_
Public Class CustomerRowProvider
Inherits Microsoft.SharePoint.WebPartPages.WebPart
Implements IRowProvider
7/28/2019 2435110.pdf
17/160
Lab Resource Toolkit 13
How To: Add Child Controls to Web Parts
Tasks Supporting information
1. Verify that the CustomerRowProvider code
includes declarations for:
A drop-down list representing Customer ID.
Ten labels representing:
CompanyName
ContactName
ContactTitle
Address
City
PostalCode
Country
PhoneNumber
FaxNumber
Error for display when an exception
occurs
DataSet for all customer records.
DataRow for the currently selected currently
selected customers data.
2. Declare two string arrays called fieldList and
fieldDisplayList.
3. Override the CreateChildControls method of
System.Web.UI.Control. by performing thefollowing steps:
Instantiate the controls.
Set their properties.
Hook up to any event handlers.
Add the controls to the Controls collection
property of the Web Part, which is inherited
from System.Web.UI.Control.
a. Instantiate the Error Label.
b. Set the Error Labels Visibility property to false.
c. Add the Error Label to the Control collection.
d. Create the drop-down list forCustomerId and
attach the event forSelectedIndexChanged.
e. Instantiate remainder label controls setting the
width to fill 100% of its table cell, adding them to
the Controls collection, and setting the
appropriate field array values.
7/28/2019 2435110.pdf
18/160
14 Lab Resource Toolkit
(continued)
Tasks Supporting information
4. Retrieve the customer data from the XML file
residing in the wpresources/Northwind
directory.
a. Load schema and data into the CustomersSet
DataSet.
b. Use the Server.MapPath method to map the
relative path.
c. If an error or exception occurs, display a message
in the error label and set its visibility property to
true.
d. Bind the drop-down list to the dataset.
e. Add an instruction to the top of the drop-down
that says -Select-.
f. Set the drop-down lists AutoPostBackproperty
to true.
g.Click the
Savetoolbar icon.
Note When you open a new solution in Microsoft Visual Studio using the Web Part templatesyou will notice that some code is already included. In the code samples below, any code
provided by Microsoft Visual Studio Web Part templates is italicized.
For example, code included by Microsoft Visual Studio Web Part templates looks like:
using System;
Code that you will enter looks like:
[DefaultProperty("Text"),
7/28/2019 2435110.pdf
19/160
Lab Resource Toolkit 15
C# Code Samples
Exercise #2, Task #1
// Objects used to manage and marshal customer data.
protected DataSet CustomersSet = new DataSet();
protected DataRow CurrentRow;
protected DropDownList CustomerIdChooser;
protected Label CompanyNameLabel;
protected Label ContactNameLabel;
protected Label ContactTitleLabel;
protected Label AddressLabel;
protected Label CityLabel;
protected Label PostalCodeLabel;
protected Label CountryLabel;
protected Label PhoneNumberLabel;
protected Label FaxNumberLabel;protected Label ErrorLabel;
7/28/2019 2435110.pdf
20/160
16 Lab Resource Toolkit
Exercise #2, Task #2
// Variables used in PartCommunicationInit and
GetInitEventArgs.
// Populated in CreateChildControls
private string[] _fieldList;private string[] _fieldDisplayList;
7/28/2019 2435110.pdf
21/160
Lab Resource Toolkit 17
Exercise #2, Task #3
protected override void CreateChildControls()
{
// This label is displayed only if
// an exception is thrown while attempting// to load the data.
ErrorLabel = new Label();
ErrorLabel.Visible = false;
Controls.Add(ErrorLabel);
// Create dropdown list and hook events.
CustomerIdChooser = new DropDownList();
CustomerIdChooser.Load += new
EventHandler(CustomerIdLoad);
CustomerIdChooser.SelectedIndexChanged += new
EventHandler(CustomerIdChanged);
Controls.Add(CustomerIdChooser);
// Populate arrays used in
// PartCommunicationInit and GetInitEventArgs
_fieldList = new string[10];
_fieldDisplayList = new string[10];
_fieldList[0] = "CustomerID";
_fieldDisplayList[0] = "Customer ID";
// All labels will fill the
// available width in their table cells.
Unit standardWidth = new Unit("100%");
// Create labels to display customer data,// and populate arrays used in Init events
and methods
CompanyNameLabel = new Label();
CompanyNameLabel.Width = standardWidth;
Controls.Add(CompanyNameLabel);
_fieldList[1] = "CompanyName";
_fieldDisplayList[1] = "Company Name";
ContactNameLabel = new Label();
ContactNameLabel.Width = standardWidth;
Controls.Add(ContactNameLabel);
_fieldList[2] = "ContactName";
_fieldDisplayList[2] = "Contact Name";
ContactTitleLabel = new Label();
ContactTitleLabel.Width = standardWidth;
Controls.Add(ContactTitleLabel);
_fieldList[3] = "ContactTitle";
_fieldDisplayList[3] = "Contact Title";
(Code continued on the following page.)
7/28/2019 2435110.pdf
22/160
18 Lab Resource Toolkit
AddressLabel = new Label();
AddressLabel.Width = standardWidth;
Controls.Add(AddressLabel);
_fieldList[4] = "Address";
_fieldDisplayList[4] = "Address";
CityLabel = new Label();CityLabel.Width = standardWidth;
Controls.Add(CityLabel);
_fieldList[5] = "City";
_fieldDisplayList[5] = "City";
PostalCodeLabel = new Label();
PostalCodeLabel.Width = standardWidth;
Controls.Add(PostalCodeLabel);
_fieldList[6] = "PostalCode";
_fieldDisplayList[6] = "Postal Code";
CountryLabel = new Label();
CountryLabel.Width = standardWidth;Controls.Add(CountryLabel);
_fieldList[7] = "Country";
_fieldDisplayList[7] = "Country";
PhoneNumberLabel = new Label();
PhoneNumberLabel.Width = standardWidth;
Controls.Add(PhoneNumberLabel);
_fieldList[8] = "Phone";
_fieldDisplayList[8] = "Phone Number";
FaxNumberLabel = new Label();
FaxNumberLabel.Width = standardWidth;
Controls.Add(FaxNumberLabel);_fieldList[9] = "Fax";
_fieldDisplayList[9] = "Fax Number";
}
7/28/2019 2435110.pdf
23/160
Lab Resource Toolkit 19
Exercise #2, Task #4
// CustomerIdLoad
// handles CustomerIdChooser.Load.
public void CustomerIdLoad(object sender,
EventArgs e){
// Load schema and data into the CustomersSet
DataSet.
// (Caching could be used to avoid reading
from disk each time.)
// Assumes XML file is in the
wpresources/Northwind folder.
// Use exception handling in case the code
cannot read the file.
try
{
string customerXmlFile =
Page.Server.MapPath(@"/wpresources/Northwind/Custome
rs.XML");
CustomersSet.ReadXml(customerXmlFile,
XmlReadMode.ReadSchema);
}
catch (System.Security.SecurityException ex)
{
ErrorLabel.Text =
ex.Message + "
" +
"Steps to correct this are included
in" +
" the documentation for this sample.";ErrorLabel.Visible = true;
return;
}
catch (Exception ex)
{
ErrorLabel.Text = ex.Message;
ErrorLabel.Visible = true;
return;
}
(Code continued on the following page.)
7/28/2019 2435110.pdf
24/160
20 Lab Resource Toolkit
// No error if we made it this far.
ErrorLabel.Visible = false;
if (CustomerIdChooser.Items.Count==0)
{
// Bind data.
CustomerIdChooser.DataSource =CustomersSet.Tables["Customers"];
CustomerIdChooser.DataTextField =
"CustomerID";
CustomerIdChooser.DataValueField =
"CustomerID";
CustomerIdChooser.DataBind();
// Add an instruction item at the top of
the list.
CustomerIdChooser.Items.Insert(0, new
ListItem("-Select-", ""));
// Trigger a postback when a customer isselected.
CustomerIdChooser.AutoPostBack = true;
}
}
7/28/2019 2435110.pdf
25/160
Lab Resource Toolkit 21
VB .NET Code Samples
Exercise #2, Task #1
' Objects used to manage and marshal customer data
Protected CustomersSet As New DataSetProtected CurrentRow As DataRow
Protected CustomerIdChooser As DropDownList
Protected CompanyNameLabel As Label
Protected ContactNameLabel As Label
Protected ContactTitleLabel As Label
Protected AddressLabel As Label
Protected CityLabel As Label
Protected PostalCodeLabel As Label
Protected CountryLabel As Label
Protected PhoneNumberLabel As Label
Protected FaxNumberLabel As Label
Protected ErrorLabel As Label
7/28/2019 2435110.pdf
26/160
22 Lab Resource Toolkit
Exercise #2, Task #2
' Variables used in PartCommunicationInit and
GetInitEventArgs.
' Populated in CreateChildControls
Private _fieldList() As StringPrivate _fieldDisplayList() As String
7/28/2019 2435110.pdf
27/160
Lab Resource Toolkit 23
Exercise #2, Task #3
' CreateChildControls
' Override CreateChildControls to add
' child ASP.NET controls to this WebPart control.
' This method is also used to populate' the _fieldList and _fieldDisplayList arrays.
'
Protected Overrides Sub CreateChildControls()
' This label is displayed only if
' an exception is thrown while attempting
' to load the data.
ErrorLabel = New Label
ErrorLabel.Visible = False
Controls.Add(ErrorLabel)
' Create dropdown list and hook events.
CustomerIdChooser = New DropDownList
AddHandler CustomerIdChooser.Load, AddressOf
CustomerIdLoad
AddHandler CustomerIdChooser.SelectedIndexChanged,
AddressOf CustomerIdChanged
Controls.Add(CustomerIdChooser)
' Populate arrays used in
' PartCommunicationInit and GetInitEventArgs
ReDim _fieldList(10)
ReDim _fieldDisplayList(10)
_fieldList(0) = "CustomerID"
_fieldDisplayList(0) = "Customer ID"
' All labels will fill the
' available width in their table cells.
Dim standardWidth As Unit = New Unit("100%")
' Create labels to display customer data,
' and populate arrays used in Init events and
methods
CompanyNameLabel = New Label
CompanyNameLabel.Width = standardWidth
Controls.Add(CompanyNameLabel)
_fieldList(1) = "CompanyName"
_fieldDisplayList(1) = "Company Name"
ContactNameLabel = New Label
ContactNameLabel.Width = standardWidth
Controls.Add(ContactNameLabel)
_fieldList(2) = "ContactName"
_fieldDisplayList(2) = "Contact Name"
(Code continued on the following page.)
7/28/2019 2435110.pdf
28/160
24 Lab Resource Toolkit
ContactTitleLabel = New Label
ContactTitleLabel.Width = standardWidth
Controls.Add(ContactTitleLabel)
_fieldList(3) = "ContactTitle"
_fieldDisplayList(3) = "Contact Title"
AddressLabel = New LabelAddressLabel.Width = standardWidth
Controls.Add(AddressLabel)
_fieldList(4) = "Address"
_fieldDisplayList(4) = "Address"
CityLabel = New Label
CityLabel.Width = standardWidth
Controls.Add(CityLabel)
_fieldList(5) = "City"
_fieldDisplayList(5) = "City"
PostalCodeLabel = New Label
PostalCodeLabel.Width = standardWidthControls.Add(PostalCodeLabel)
_fieldList(6) = "PostalCode"
_fieldDisplayList(6) = "Postal Code"
CountryLabel = New Label
CountryLabel.Width = standardWidth
Controls.Add(CountryLabel)
_fieldList(7) = "Country"
_fieldDisplayList(7) = "Country"
PhoneNumberLabel = New Label
PhoneNumberLabel.Width = standardWidth
Controls.Add(PhoneNumberLabel)_fieldList(8) = "Phone"
_fieldDisplayList(8) = "Phone Number"
FaxNumberLabel = New Label
FaxNumberLabel.Width = standardWidth
Controls.Add(FaxNumberLabel)
_fieldList(9) = "Fax"
_fieldDisplayList(9) = "Fax Number"
End Sub
7/28/2019 2435110.pdf
29/160
Lab Resource Toolkit 25
Exercise #2, Task #4
' CustomerIdLoad
' handles CustomerIdChooser.Load.
Public Sub CustomerIdLoad(ByVal sender As Object, ByVal
e As EventArgs)' Load schema and data into the CustomersSet
DataSet.
' (Caching could be used to avoid reading from disk
each time.)
' Assumes XML file is in the wpresources/Northwind
folder.
' Use exception handling in case the code cannot
read the file.
Try
Dim customerXmlFile As String =
Page.Server.MapPath("/wpresources/Northwind/Customers.XML")
CustomersSet.ReadXml(customerXmlFile,
XmlReadMode.ReadSchema)
Catch ex As System.Security.SecurityException
ErrorLabel.Text = _
ex.Message + "
" + _
"Steps to correct this are included in" + _
" the documentation for this sample."
ErrorLabel.Visible = True
Return
Catch ex As Exception
ErrorLabel.Text = ex.Message
ErrorLabel.Visible = True
Return
End Try
' No error if we made it this far.
ErrorLabel.Visible = False
If CustomerIdChooser.Items.Count = 0 Then
' Bind data.
CustomerIdChooser.DataSource =
CustomersSet.Tables("Customers")
CustomerIdChooser.DataTextField = "CustomerID"
CustomerIdChooser.DataValueField = "CustomerID"
CustomerIdChooser.DataBind()
' Add an instruction item at the top of thelist.
CustomerIdChooser.Items.Insert(0, New
ListItem("-Select-", ""))
' Trigger a postback when a customer is
selected.
CustomerIdChooser.AutoPostBack = True
End If
End Sub
7/28/2019 2435110.pdf
30/160
26 Lab Resource Toolkit
How To: Render the HTML for a Web Part
Tasks Supporting information
1. Begin the RenderWebPart
method by calling
EnsureChildControls.
2. Emit the HTML necessary to
render desired output in the
RenderWebPart method.
Please type the appropriate block of code below into the starter project for
this lab.
a. Create a div tag to enclose all contents.
b. Begin a table.
c. Use AddStyleAttribute to create combined CSS style attributes.
d. Call the RenderControl method of the ASP.NET server controls,
passing the HtmlTextWriter object.
e. Test ifDetailViewEnabled property, and render the remaining
customer info if it is true.f. Click the Save toolbar icon.
Note When you open a new solution in Microsoft Visual Studio .NET using the Web Parttemplates you will notice that some code is already included. In the code samples below, anycode provided by Microsoft Visual Studio .NET Web Part templates is italicized.
For example, code included by Microsoft Visual Studio .NET Web Part templates looks like:
using System;
Code that you will enter looks like:
[DefaultProperty("Text"),
7/28/2019 2435110.pdf
31/160
Lab Resource Toolkit 27
C# Code Samples
Exercise #3, Task #1
protected override void
RenderWebPart(HtmlTextWriter output){
// The EnsureChildControls method of
// System.Web.UI.Control calls the
// CreateChildControls method only if the
// ChildControlsCreated property is false.
EnsureChildControls();
7/28/2019 2435110.pdf
32/160
28 Lab Resource Toolkit
Exercise #3, Task #2
if (ErrorLabel.Visible == false)
{
// Create a div tag to enclose all contents.
// Add attributes for the beginning tag// before calling BeginTag.
output.AddAttribute(HtmlTextWriterAttribute.Cellpadding,
"2px");
output.RenderBeginTag("div");
// Begin a table.
output.AddAttribute(HtmlTextWriterAttribute.Width, "400px");
output.AddAttribute(HtmlTextWriterAttribute.Cellpadding,
"2px");
output.AddAttribute(HtmlTextWriterAttribute.Cellspacing,
"1px");
output.RenderBeginTag("table");
output.RenderBeginTag("tr");
// Use AddStyleAttribute to create combined CSS
style attributes.
// For example: style="font-
weight:boldwidth:200px"
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,"bold");
output.AddStyleAttribute(HtmlTextWriterStyle.Width,
"200px");
output.RenderBeginTag("td");
// You can hard-code HTML, using output.Write
output.Write("Customer ID:");
output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
(Code continued on the following page.)
7/28/2019 2435110.pdf
33/160
Lab Resource Toolkit 29
// Call the RenderControl method
// of ASP.NET server controls, passing in
// the HtmlTextWriter object (output).
this.CustomerIdChooser.RenderControl(output);
output.RenderEndTag(); //td
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold");
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("Company Name:");
output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("");
this.CompanyNameLabel.RenderControl(output);
output.Write("");output.RenderEndTag(); //td
output.RenderEndTag(); //tr
// Render the remaining customer info
// only if the custom DetailViewEnabled
// property is true.
if (DetailViewEnabled == true)
{
output.RenderBeginTag("tr");
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold");
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("Contact Name:");
output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("");
this.ContactNameLabel.RenderControl(output);
output.Write("");
output.RenderEndTag(); //td
(Code continued on the following page.)
7/28/2019 2435110.pdf
34/160
30 Lab Resource Toolkit
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold");
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("Contact Title:");output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("");
this.ContactTitleLabel.RenderControl(output);
output.Write("");
output.RenderEndTag(); //td
output.RenderEndTag(); //tr
output.RenderBeginTag("tr");
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold");
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("Address:");
output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("");
this.AddressLabel.RenderControl(output);
output.Write("");
output.RenderEndTag(); //td
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold");
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("City:");
output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("");
this.CityLabel.RenderControl(output);
output.Write("");
output.RenderEndTag(); //td
(Code continued on the following page.)
7/28/2019 2435110.pdf
35/160
Lab Resource Toolkit 31
output.RenderEndTag(); //tr
output.RenderBeginTag("tr");
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold"); output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("Country:");
output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("");
this.CountryLabel.RenderControl(output);
output.Write("");output.RenderEndTag(); //td
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold");
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("Postal
Code:");
output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");output.Write("");
this.PostalCodeLabel.RenderControl(output);
output.Write("");
output.RenderEndTag(); //td
output.RenderEndTag(); //tr
output.RenderBeginTag("tr");
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold");
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("Phone
Number:");
output.RenderEndTag(); //td
(Code continued on the following page.)
7/28/2019 2435110.pdf
36/160
32 Lab Resource Toolkit
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("");
this.PhoneNumberLabel.RenderControl(output);
output.Write("");
output.RenderEndTag(); //td
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold");
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("Fax
Number:");
output.RenderEndTag(); //td
output.AddAttribute("width", "200px");
output.RenderBeginTag("td");
output.Write("");
this.FaxNumberLabel.RenderControl(output);
output.Write("");
output.RenderEndTag(); //td
output.RenderEndTag(); //tr
} // End of detail view rendering.
// Close the table and div
output.RenderEndTag(); //table
output.RenderEndTag(); //div}
else // (ErrorLabel.Visible == true)
{
// If ErrorLabel is visible, then
// an exception was raised in
// CustomerIdLoad, and ErrorLabel.Text
// was assigned an error message.
ErrorLabel.RenderControl(output);
}
}
7/28/2019 2435110.pdf
37/160
Lab Resource Toolkit 33
VB .NET Code Samples
Exercise #3, Task #1
Protected Overrides Sub RenderWebPart(ByVal output As
System.Web.UI.HtmlTextWriter)' The EnsureChildControls method of
' System.Web.UI.Control calls the
' CreateChildControls method only if the
' ChildControlsCreated property is false.
EnsureChildControls()
7/28/2019 2435110.pdf
38/160
34 Lab Resource Toolkit
Exercise #3, Task #2
If ErrorLabel.Visible = False Then
' Create a div tag to enclose all contents.
' Add attributes for the beginning tag
' before calling BeginTag.
output.AddAttribute(HtmlTextWriterAttribute.Cellpadding,
"2px")
output.RenderBeginTag("div")
' Begin a table.
output.AddAttribute(HtmlTextWriterAttribute.Width, "400px")
output.AddAttribute(HtmlTextWriterAttribute.Cellpadding,
"2px")
output.AddAttribute(HtmlTextWriterAttribute.Cellspacing,
"1px")
output.RenderBeginTag("table")
output.RenderBeginTag("tr")
' Use AddStyleAttribute to create combined CSS
style attributes.
' For example: style="font-
weight:boldwidth:200px"
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddStyleAttribute(HtmlTextWriterStyle.Width, "200px")
output.RenderBeginTag("td")
' You can hard-code HTML, using output.Write
output.Write("Customer ID:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
' Call the RenderControl method
' of ASP.NET server controls, passing in' the HtmlTextWriter object (output).
CustomerIdChooser.RenderControl(output)
(Code continued on the following page.)
7/28/2019 2435110.pdf
39/160
Lab Resource Toolkit 35
output.RenderEndTag() 'td
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")output.Write("Company Name:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
CompanyNameLabel.RenderControl(output)
output.Write("")
output.RenderEndTag() 'td
output.RenderEndTag() 'tr
' Render the remaining customer info
' only if the custom DetailViewEnabled
' property is true.
If DetailViewEnabled = True Then
output.RenderBeginTag("tr")
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("Contact Name:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
ContactNameLabel.RenderControl(output)
output.Write("")
output.RenderEndTag() 'td
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("Contact Title:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
ContactTitleLabel.RenderControl(output)
output.Write("")
output.RenderEndTag() 'td
(Code continued on the following page.)
7/28/2019 2435110.pdf
40/160
36 Lab Resource Toolkit
output.RenderEndTag() 'tr
output.RenderBeginTag("tr")
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("Address:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
AddressLabel.RenderControl(output)
output.Write("")
output.RenderEndTag() 'td
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("City:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
CityLabel.RenderControl(output)output.Write("")
output.RenderEndTag() 'td
output.RenderEndTag() 'tr
output.RenderBeginTag("tr")
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("Country:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
CountryLabel.RenderControl(output)
output.Write("")
output.RenderEndTag() 'td
(Code continued on the following page.)
7/28/2019 2435110.pdf
41/160
Lab Resource Toolkit 37
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("Postal Code:")output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
PostalCodeLabel.RenderControl(output)
output.Write("")
output.RenderEndTag() 'td
output.RenderEndTag() 'tr
output.RenderBeginTag("tr")
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("Phone Number:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
PhoneNumberLabel.RenderControl(output)
output.Write("")output.RenderEndTag() 'td
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight,
"bold")
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("Fax Number:")
output.RenderEndTag() 'td
output.AddAttribute("width", "200px")
output.RenderBeginTag("td")
output.Write("")
FaxNumberLabel.RenderControl(output)
output.Write("")
output.RenderEndTag() 'td
output.RenderEndTag() 'tr
End If ' End of detail view rendering.
(Code continued on the following page.)
7/28/2019 2435110.pdf
42/160
38 Lab Resource Toolkit
' Close the table and div
output.RenderEndTag() 'table
output.RenderEndTag() 'div
Else ' (ErrorLabel.Visible == true)
' If ErrorLabel is visible, then
' an exception was raised in' CustomerIdLoad, and ErrorLabel.Text
' was assigned an error message.
ErrorLabel.RenderControl(output)
End If
End Sub
7/28/2019 2435110.pdf
43/160
Lab Resource Toolkit 39
How To: Create and Display Custom Properties
Tasks Supporting information
1. Create a custom property to
enable detailed customer
information to be switched on
or off using the tool pane.
a. Declare a constant Boolean for the default value of the property and
set it to false.
b. Create a Boolean variable and set it to the default value.
c. Create the property.
2. Override the GetToolParts
method to customize how to
display your properties.
a. Add a CustomPropertyToolPart object to the ToolPart array that
the method returns.
b. Move the custom property to the top of the task pane by relocating it
to the first position in the array.
c. Specify that the custom View category should be expanded. The
other categories are collapsed by default when the task pane opens.
d. Click the Save toolbar icon.
Note When you open a new solution in Microsoft Visual Studio using the Web Part templatesyou will notice that some code is already included. In the code samples below, any code
provided by Microsoft Visual Studio Web Part templates is italicized.
For example, code included by Microsoft Visual Studio Web Part templates looks like:
using System;
Code that you will enter looks like:
[DefaultProperty("Text"),
7/28/2019 2435110.pdf
44/160
40 Lab Resource Toolkit
C# Code Samples
Exercise #4, Task #1
// A custom property controls how much
// data is displayed about the selectedcustomer.
const bool DetailViewEnabled_Default = false;
private bool _detailViewEnabled =
DetailViewEnabled_Default;
// Attributes to control display in the tool
pane property browser.
// The property is Browsable by default.
// Property settings can be stored for each
user.
// This Boolean property will automatically
// be represented by a check box in the tool
pane.[Description("Enable display of details about
this customer."),
Category("View"),
DefaultValue(DetailViewEnabled_Default),
FriendlyName("Enable detailed view")]
[WebPartStorage(Storage.Personal)]
public bool DetailViewEnabled
{
get
{
return _detailViewEnabled;
}
set
{
_detailViewEnabled = value;
}
}
7/28/2019 2435110.pdf
45/160
Lab Resource Toolkit 41
Exercise #4, Task #2
public override ToolPart[ ] GetToolParts()
{
ToolPart[ ] toolparts = new ToolPart[2];
CustomPropertyToolPart cp = newCustomPropertyToolPart();
cp.Expand("View");
toolparts[0] = cp;
toolparts[1] = new WebPartToolPart();
return toolparts;
}
7/28/2019 2435110.pdf
46/160
42 Lab Resource Toolkit
VB .NET Code Samples
Exercise #4, Task #1
' A custom property controls how much
' data is displayed about the selected customer.Const DetailViewEnabled_Default As Boolean = False
Private _detailViewEnabled As Boolean =
DetailViewEnabled_Default
' Attributes to control display in the tool pane
property browser.
' The property is Browsable by default.
' Property settings can be stored for each user.
' This Boolean property will automatically
' be represented by a check box in the tool pane.
_
Public Property DetailViewEnabled() As Boolean
Get
Return _detailViewEnabled
End Get
Set(ByVal Value As Boolean)
_detailViewEnabled = Value
End Set
End Property
7/28/2019 2435110.pdf
47/160
Lab Resource Toolkit 43
Exercise #4, Task #2
Public Overrides Function GetToolParts() As ToolPart()
Dim toolParts(1) As ToolPart
Dim cp As CustomPropertyToolPart = New
CustomPropertyToolPart
cp.Expand("View")
toolParts(0) = cp
toolParts(1) = New WebPartToolPart
Return toolParts
End Function
7/28/2019 2435110.pdf
48/160
44 Lab Resource Toolkit
How To: Implement Event Handlers
Tasks Supporting information
1. Override IRowProvider Events
to ensure all the Web Partsconnection interfaces are
available.
a. Override the EnsureInterfaces method.
b. Call the RegisterInterface method and provide the followingparameters:
RowProvider InterfaceName
InterfaceTypes.IRowProvider InterfaceType
WebPart.UnlimitedConnections MaxConnections
ConnectionRunAt.Server RunAt Options
this Interface Object (when using C#), or
Me Interface Object (when using VB .NET)
String.Empty Interface Client Reference
Provide Customer Data to Menu Label
Provides a row of data about the selected customer.Description
2. Override the function
CanRunAt that enables the Web
Part to run on either the client or
the server.
Return ConnectionRunAt.Server.
3. Override the function
PartCommunicationConnect
that enables the framework to
notify the Web Part that it is
connected.
4. Override the functionPartCommunicationInit which
provides initialization data to the
consumer.
a. Create a RowProviderInitEventArgs object.
b. Set the FieldList property to the fieldList variable.
c. Set the FieldDisplayList property to the fieldDisplayList
variable.
d. Raise the RowProviderInit eventand pass the
RowProviderInitEventArgs object to it.
5. Override the function
PartCommunicationMain
which fires remaining events of
the interface.
a. Create a RowReadyEventArgs object.
b. Assign a DataRow array to the Rows property.
c. Set SelectionStatus to Standard.
d. Raise the RowReady eventand pass the RowReadyEventArgs
object.
7/28/2019 2435110.pdf
49/160
Lab Resource Toolkit 45
(continued)
Tasks Supporting information
6. Override the function
GetInitEventArgs which
provides data to the authoring
environment that is creating the
transformer dialogs.
a. Test if the parameterinterfaceName is equal to RowProvider.
b. Call the EnsureChildControls method.c. Create a RowProviderInitEventArgs object.
d. Set the FieldList property to the fieldList variable.
e. Set the FieldDisplayList property to the fieldList variable.
f. Return the RowProviderInitEventArgs object.
7. Provide the two events:
RowProviderInitEventHandler
and RowReadyEventHandler.
Note When you open a new solution in Microsoft Visual Studio using the Web Part templates
you will notice that some code is already included. In the code samples below, any codeprovided by Microsoft Visual Studio Web Part templates is italicized.
For example, code included by Microsoft Visual Studio Web Part templates looks like:
using System;
Code that you will enter looks like:
[DefaultProperty("Text"),
7/28/2019 2435110.pdf
50/160
46 Lab Resource Toolkit
C# Code Samples
Exercise #5, Task #1
///
/// EnsureInterfaces/// This method is called by the
framework.
/// Use it to ensure that all the Web
Part's
/// connection interfaces are
registered.
///
///
public override void EnsureInterfaces()
{
/*
Call RegisterInterface for each Web
Part connection interface.Parameters:
- InterfaceName: Name assigned to
this interface.
Use a unique name for each
interface registered by this part.
- InterfaceType: The name of the
interface type.
Use constants provided by the
InterfaceTypes class.
- MaxConnections: The number allowed
for this interface,
either one or unlimited.
- RunAtOptions: Where the
connections can be implemented,
on the server, the client,
neither, or both.
- InterfaceObject: A reference to
this WebPart,
the object implementing the
interface.
- InterfaceClientReference: For
client-side connections,
an identifier for the client-side
object that
implements this interface.Use the _WPQ_ token to generate a
unique ID.
Use String.Empty for server-side
connections.
(Code continued on the following page.)
7/28/2019 2435110.pdf
51/160
Lab Resource Toolkit 47
- MenuLabel: Label for the interface
that appears in the
Connections submenu when a user is
authoring connections.
- Description: an extended
explanation of the
interface, used in some authoringenvironments.
*/
RegisterInterface(
"RowProvider",
// InterfaceName
InterfaceTypes.IRowProvider, //
InterfaceType
WebPart.UnlimitedConnections, //
MaxConnections
ConnectionRunAt.Server,
// RunAtOptions
this,
// InterfaceObjectString.Empty,
// InterfaceClientReference
"Provide Customer Data to",
// MenuLabel
"Provides a row of data about the
selected customer."); // Description
}
7/28/2019 2435110.pdf
52/160
48 Lab Resource Toolkit
Exercise #5, Task #2
///
/// CanRunAt
/// Called by the framework to determine whether
a part thinks/// that it can be run on the client or server
based on the current
/// configuration.
///
///
public override ConnectionRunAt CanRunAt()
{
//This Web Part runs on the server
return ConnectionRunAt.Server;
}
7/28/2019 2435110.pdf
53/160
Lab Resource Toolkit 49
Exercise #5, Task #3
///
/// PartCommunicationConnect
/// Notification to the Web Part that it has
been connected./// The framework calls this method after a
connection
/// interface has been registered.
///
///
/// Unique name of the interface being
connected
///
/// Reference to the Web Part that this one is
connecting to
///
/// Unique name of the interface on the other
Web Part
///
/// Where the interface events should
execute
///
public override void PartCommunicationConnect(
string interfaceName,
WebPart connectedPart,
string connectedInterfaceName,
ConnectionRunAt runAt)
{
// Ensure that any child controls have been
created. EnsureChildControls();
// This method provides data identifying
which interface
// has been connected, and which other part
and interface
// this part was connected to.
// Code here could provide special behavior
for
// certain interfaces or for connections with
certain
// known parts. None is needed here.
}
7/28/2019 2435110.pdf
54/160
50 Lab Resource Toolkit
Exercise #5, Task #4
///
/// PartCommunicationInit
/// Raise interface Init events
/// in this method, to send initialization data/// to the consumer.
///
public override void PartCommunicationInit()
{
// Raise event if a handler has been assigned
to the delegate.
if (RowProviderInit != null)
{
// Create an EventArgs object for the
event
RowProviderInitEventArgs
rowProviderInitEventArgs = new RowProviderInitEventArgs();
// Set the FieldList and FieldDisplayList
// properties of the EventArgs object.
// These values may be used by the
consumer part.
rowProviderInitEventArgs.FieldList =
_fieldList;
rowProviderInitEventArgs.FieldDisplayList
= _fieldDisplayList;
// Raise the rowProviderInit event, which
passes the EventArgs data to the// consumer part.
RowProviderInit(this,
rowProviderInitEventArgs);
}
}
7/28/2019 2435110.pdf
55/160
Lab Resource Toolkit 51
Exercise #5, Task #5
///
/// PartCommunicationMain
/// Overriding this method is optional.
/// Use it to fire any remaining/// events of the interface.
/// For IRowProvider, fire the RowReady event,
/// to send the row data to any consumers.
///
///
public override void PartCommunicationMain()
{
// Raise the event if a handler has been
assigned to the delegate.
if (RowReady != null)
{
// Create the required EventArgs object.
RowReadyEventArgs rowReadyEventArgs = new
RowReadyEventArgs();
// Assign a DataRow array to the Rows
property.
rowReadyEventArgs.Rows = new
DataRow[1]{CurrentRow};
// Set SelectionStatus to one
// of these case sensitive strings:
// "New" -- For grids that have a "New"
(star) row.
// "None" -- No row is selected.// "Standard" -- Normal selection of row
or rows.
rowReadyEventArgs.SelectionStatus =
"Standard";
// Fire the RowReady event
// to send the data to
// any registered consumers.
RowReady(this, rowReadyEventArgs);
}
}
7/28/2019 2435110.pdf
56/160
52 Lab Resource Toolkit
Exercise #5, Task #6
///
/// GetInitEventArgs
/// Override this method only for interfaces
/// that can use transformers, to provide data/// to the authoring evironment that is creating
/// the transformer dialogs.
/// The IRowProvider interface can
/// use transformers to provide data
/// to an ICellConsumer or an IFilterConsumer.
///
///
/// Name of interface that the framework is
/// requesting information on
/// An EventArgs object such as
RowProviderInitEventArgs
///
public override InitEventArgs
GetInitEventArgs(string interfaceName)
{
// Check that this call is for the
interface implemented in this class.
if (interfaceName == "RowProvider")
{
// Create child controls, if
necessary.
EnsureChildControls();
// Create the EventArgs object for
this interface. RowProviderInitEventArgs
rowProviderInitEventArgs = new RowProviderInitEventArgs();
// Set the FieldList and
FieldDisplayList,
// which are used by the authoring
environment
// to create the transformer dialogs.
rowProviderInitEventArgs.FieldList =
_fieldList;
rowProviderInitEventArgs.FieldDisplayList =
_fieldDisplayList;
//return the InitArgs
return(rowProviderInitEventArgs);
}
else
{
return(null);
}
}
7/28/2019 2435110.pdf
57/160
Lab Resource Toolkit 53
Exercise #5, Task #7
// Events required by the IRowProvider interface.
public event RowProviderInitEventHandler
RowProviderInit;
public event RowReadyEventHandler RowReady;
7/28/2019 2435110.pdf
58/160
54 Lab Resource Toolkit
VB .NET Code Samples
Exercise #5, Task #1
' EnsureInterfaces
' This method is called by the framework.' Use it to ensure that all the Web Part's
' connection interfaces are registered.
Public Overrides Sub EnsureInterfaces()
'
' Call RegisterInterface for each Web Part
connection interface.
' Parameters:
' - InterfaceName: Name assigned to this
interface.
' Use a unique name for each interface
registered by this part.
' - InterfaceType: The name of the interface
type.' Use constants provided by the
InterfaceTypes class.
' - MaxConnections: The number allowed for
this interface,
' either one or unlimited.
' - RunAtOptions: Where the connections can be
implemented,
' on the server, the client, neither, or
both.
' - InterfaceObject: A reference to this
WebPart,
' the object implementing the interface.
' - InterfaceClientReference: For client-side
connections,
' an identifier for the client-side object
that
' implements this interface.
' Use the _WPQ_ token to generate a
unique ID.
' Use String.Empty for server-side
connections.
' - MenuLabel: Label for the interface that
appears in the
' Connections submenu when a user is
authoring connections.' - Description: an extended explanation of
the
' interface, used in some authoring
environments.
'
(Code continued on the following page.)
7/28/2019 2435110.pdf
59/160
Lab Resource Toolkit 55
Try
'Register the ICellProvider interface
RegisterInterface("RowProvider",
InterfaceTypes.IRowProvider, WebPart.UnlimitedConnections,
ConnectionRunAt.Server, Me, String.Empty, "Provide Customer
Data to", "Provides a row of data about the selected
customer.")Catch e As SecurityException
End Try
End Sub
7/28/2019 2435110.pdf
60/160
56 Lab Resource Toolkit
Exercise #5, Task #2
'This method is called by the framework to determine
whether a part
'can be run on the client or server based on the current
'configuration.Public Overrides Function CanRunAt() As ConnectionRunAt
Return ConnectionRunAt.Server
End Function
7/28/2019 2435110.pdf
61/160
Lab Resource Toolkit 57
Exercise #5, Task #3
' PartCommunicationConnect
' Notification to the Web Part that it has been
connected.
' The framework calls this method after a connection' interface has been registered.
'
' Unique name of the interface being connected
'
' Reference to the Web Part that this one is connecting
to
'
' Unique name of the interface on the other Web
Part
'
' Where the interface events should execute
'
Public Overrides Sub PartCommunicationConnect(ByVal
InterfaceName As String, ByVal connectedPart As
Microsoft.SharePoint.WebPartPages.WebPart, ByVal
connectedInterfaceName As String, ByVal runAt As
Microsoft.SharePoint.WebPartPages.Communication.ConnectionRu
nAt)
' Ensure that any child controls have been created.
EnsureChildControls()
' This method provides data identifying which
interface
' has been connected, and which other part and
interface' this part was connected to.
' Code here could provide special behavior for
' certain interfaces or for connections with certain
' known parts. None is needed here.
End Sub
7/28/2019 2435110.pdf
62/160
58 Lab Resource Toolkit
Exercise #5, Task #4
'
' PartCommunicationInit
' Raise interface Init events
' in this method, to send initialization data' to the consumer.
'
Public Overrides Sub PartCommunicationInit()
' Raise event if a handler has been assigned to the
delegate.
EnsureChildControls()
' Create an EventArgs object for the event
Dim rowProviderInitEventArgs As
RowProviderInitEventArgs = New RowProviderInitEventArgs
' Set the FieldList and FieldDisplayList
' properties of the EventArgs object.
' These values may be used by the consumer part.
rowProviderInitEventArgs.FieldList = _fieldList
rowProviderInitEventArgs.FieldDisplayList =
_fieldDisplayList
' Raise the rowProviderInit event, which passes the
EventArgs data to the
' consumer part.
RaiseEvent RowProviderInit(Me,
rowProviderInitEventArgs)
End Sub
7/28/2019 2435110.pdf
63/160
Lab Resource Toolkit 59
Exercise #5, Task #5
'In this method, a part can fire any events that it
requires to.
Public Overrides Sub PartCommunicationMain()
EnsureChildControls()' Create the required EventArgs object.
Dim rowReadyEventArgs As RowReadyEventArgs = New
RowReadyEventArgs
' Assign a DataRow array to the Rows property.
rowReadyEventArgs.Rows = New DataRow(0) {CurrentRow}
' Set SelectionStatus to one
' of these case sensitive strings:
' "New" -- For grids that have a "New" (star) row.
' "None" -- No row is selected.
' "Standard" -- Normal selection of row or rows.
rowReadyEventArgs.SelectionStatus = "Standard"
' Fire the RowReady event
' to send the data to
' any registered consumers.
RaiseEvent RowReady(Me, rowReadyEventArgs)
End Sub
7/28/2019 2435110.pdf
64/160
60 Lab Resource Toolkit
Exercise #5, Task #6
'
' GetInitEventArgs
' Override this method only for interfaces
' that can use transformers, to provide data' to the authoring evironment that is creating
' the transformer dialogs.
' The IRowProvider interface can
' use transformers to provide data
' to an ICellConsumer or an IFilterConsumer.
'
'
' Name of interface that the framework is
' requesting information on
' An EventArgs object such as
RowProviderInitEventArgs
'
Public Overrides Function GetInitEventArgs(ByVal
interfaceName As String) As InitEventArgs
' Check that this call is for the interface
implemented in this class.
If interfaceName = "RowProvider" Then
' Create child controls, if necessary.
EnsureChildControls()
' Create the EventArgs object for this
interface.
Dim rowProviderInitEventArgs As
RowProviderInitEventArgs = New RowProviderInitEventArgs
' Set the FieldList and FieldDisplayList,
' which are used by the authoring environment
' to create the transformer dialogs.
rowProviderInitEventArgs.FieldList = _fieldList
rowProviderInitEventArgs.FieldDisplayList =
_fieldDisplayList
'return the InitArgs
Return (rowProviderInitEventArgs)
Else
Return (Nothing)
End If
End Function
7/28/2019 2435110.pdf
65/160
Lab Resource Toolkit 61
Exercise #5, Task #7
' Events required by the IRowProvider interface.
Public Event RowProviderInit As
RowProviderInitEventHandler Implements
IRowProvider.RowProviderInitPublic Event RowReady As RowReadyEventHandler Implements
IRowProvider.RowReady
7/28/2019 2435110.pdf
66/160
62 Lab Resource Toolkit
How To: Implement Control Event Handler
Tasks Supporting information
1. Implement a function to
handle the event when the
drop down selection for
CustomerId has been
changed.
a. Try to find the DataRow that matches the selected CustomerId.
b. If a corresponding DataRow was found, bind each of the Web Partslabels to the appropriate data element.
c. If a corresponding DataRow was not found, clear each of the labels
by setting their Text value to String.Empty.
d. Click the Save toolbar icon.
e. Click the Build menu, and then clickRebuild Solution.
f. Verify there were no compilation errors. Correct any coding errors
that may have been injected.
Note When you open a new solution in Microsoft Visual Studio .NET using the Web Part
templates you will notice that some code is already included. In the code samples below, anycode provided by Microsoft Visual Studio .NET Web Part templates is italicized.
For example, code included by Microsoft Visual Studio .NET Web Part templates looks like:
using System;
Code that you will enter looks like:
[DefaultProperty("Text"),
7/28/2019 2435110.pdf
67/160
Lab Resource Toolkit 63
C# Code Samples
Exercise #6, Task #1
///
/// CustomerIDChanged/// handles CustomerIdChooser.SelectedIndexChanged.
///
public void CustomerIdChanged(object sender,
EventArgs e)
{
// Try to find a DataRow for the selected
customer.
string custID =
CustomerIdChooser.SelectedItem.Value;
CurrentRow =
CustomersSet.Tables["Customers"].Rows.Find(custID);
if (CurrentRow == null)
{// If row is not found, clear the labels.
// (This occurs when "-Select-" is
selected.)
CompanyNameLabel.Text = String.Empty;
// The following labels only show when
// DetailViewEnabled is true.
ContactNameLabel.Text = String.Empty;
ContactTitleLabel.Text =String.Empty;
AddressLabel.Text = String.Empty;
CityLabel.Text = String.Empty;
CountryLabel.Text = String.Empty;
PostalCodeLabel.Text = String.Empty;
PhoneNumberLabel.Text = String.Empty;
FaxNumberLabel.Text = String.Empty;
}
else
(Code continued on the following page.)
7/28/2019 2435110.pdf
68/160
64 Lab Resource Toolkit
{
// If a customer row is found,
// populate the labels with data.
CompanyNameLabel.Text =
CurrentRow["CompanyName"].ToString();
ContactNameLabel.Text =
CurrentRow["ContactName"].ToString();ContactTitleLabel.Text =
CurrentRow["ContactTitle"].ToString();
AddressLabel.Text =
CurrentRow["Address"].ToString();
CityLabel.Text =
CurrentRow["City"].ToString();
CountryLabel.Text =
CurrentRow["Country"].ToString();
PostalCodeLabel.Text =
CurrentRow["PostalCode"].ToString();
PhoneNumberLabel.Text =
CurrentRow["Phone"].ToString();
FaxNumberLabel.Text =CurrentRow["Fax"].ToString();
}
}
}
}
7/28/2019 2435110.pdf
69/160
Lab Resource Toolkit 65
VB .NET Code Samples
Exercise #6, Task #1
'
' CustomerIDChanged' handles CustomerIdChooser.SelectedIndexChanged.
'
Public Sub CustomerIdChanged(ByVal sender As Object,
ByVal e As EventArgs)
' Try to find a DataRow for the selected customer.
Dim custId As String =
CustomerIdChooser.SelectedItem.Value
CurrentRow =
CustomersSet.Tables("Customers").Rows.Find(custId)
If CurrentRow Is Nothing Then
' If row is not found, clear the labels.
' (This occurs when "-Select-" is selected.)
CompanyNameLabel.Text = String.Empty
' The following labels only show when
' DetailViewEnabled is true.
ContactNameLabel.Text = String.Empty
ContactTitleLabel.Text = String.Empty
AddressLabel.Text = String.Empty
CityLabel.Text = String.Empty
CountryLabel.Text = String.Empty
PostalCodeLabel.Text = String.Empty
PhoneNumberLabel.Text = String.Empty
FaxNumberLabel.Text = String.Empty
Else
(Code continued on the following page.)
7/28/2019 2435110.pdf
70/160
66 Lab Resource Toolkit
' If a customer row is found,
' populate the labels with data.
CompanyNameLabel.Text =
CurrentRow("CompanyName").ToString()
ContactNameLabel.Text =
CurrentRow("ContactName").ToString()
ContactTitleLabel.Text =CurrentRow("ContactTitle").ToString()
AddressLabel.Text =
CurrentRow("Address").ToString()
CityLabel.Text = CurrentRow("City").ToString()
CountryLabel.Text =
CurrentRow("Country").ToString()
PostalCodeLabel.Text =
CurrentRow("PostalCode").ToString()
PhoneNumberLabel.Text =
CurrentRow("Phone").ToString()
FaxNumberLabel.Text =
CurrentRow("Fax").ToString()
End IfEnd Sub
End Class
7/28/2019 2435110.pdf
71/160
Lab Resource Toolkit 67
Unit 5: Connecting Web PartsThe following sections contain the information from the Resources tab in the LabToolkit for thisunit.
Reference: Creating a Connectable Web PartThis programming task describes how to create two connectable Web Parts: a Web Part that canconsume a single cell value and another Web Part that can provide a single cell value.
About Connectable Web Parts
The Web Part architecture provides a standardized set of interfaces called connection interfaces thatallow Web Parts to exchange information with each other at runtime. For example, the List WebPart that is built into Windows SharePoint Services can provide (send) a row of data to any otherWeb Part that can consume (receive) that row, such as a Web Part that implements a form todisplay the row.
Because the Web Part architecture provides a standard set of connection interfaces, connectable
Web Parts can be developed by entirely different developers or companies to communicate withone another. A Web Part that supports connection interfaces can be connected by an end user witheither Microsoft FrontPage or a Web browser. This allows end users to build sophisticatedcombinations of Web Parts through a simple menu-driven user interface.
Connection Interfaces
Connection interfaces are paired events relevant to a specific item such as a row in a list. The pairedinterfaces form a communication bus between Web Parts that implement them. A connectable WebPart raises an interface event to one or more connected parts to make them perform an action.Interfaces are paired as a provider to a consumer. Events from the provider get handled in theconsumer and vice versa. The following table briefly describes each pair of connection interfaces.
Connection Interface Pair Connection Interface Pair
ICellProvider, ICellConsumerConnection interfaces for providing or consuming a single value item,
such as a cell or field.
IRowProvider, IRowConsumerConnection interfaces for providing or consuming a single row (or
multiple rows) of values.
IListProvider, IListConsumer Connection interfaces for providing or consuming an entire list.
IFilterProvider, IFilterConsumer
Connection interfaces for providing or consuming a filter value. For
example, the SharePoint List Web Part supports IListProvider,
IRowProvider and IFilterConsumer. Because IRowProvider can
connect to IFilterConsumer, two different SharePoint Lists can be
connected to one another. This allows one list to filter the other
connected list.
IParametersInProvider,
IParametersInConsumer
The IParameterIn interfaces allow passing and receiving any set of
arbitrary parameters between Web Parts. These interfaces cover a
situation where the consumer Web Part owns the parameter list and
needs to communicate this to other Web Parts.
I