|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
How to: Provide Optional Web Parts Controls
One feature of the Web Parts control set is the ability to make a catalog of optional controls available for an end user to add to a page.
You must provide a way for end users to view the page in catalog mode so that they can see the catalog. You can do this by setting theproperty of the local instance to catalog mode, as described in . Alternatively, you can create a user control that exposes all available page display modes and provides other useful functionality. For more information, see .
To create a catalog of optional Web Parts controls
Create an ASP.NET Web Parts page with personalization enabled. For details, see.
Add to the page azone that contains a template. This is where the user will put the controls he or she selects.
Add to the page azone that contains a template, which in turn contains a control.
Inside the DeclarativeCatalogPart control, add a pair of
<WebPartsTemplate>tags that contain the controls to include in your catalog. The markup for the CatalogZone zone should now look something like the following example.
<asp:CatalogZone ID="CZ1" runat="server"> <ZoneTemplate> <asp:DeclarativeCatalogPart ID="DCP1" runat="server"> <WebPartsTemplate> <asp:Label ID="Label1" runat="server" Text="Label" /> <asp:Button ID="Button1" runat="server" Text="Button" /> </WebPartsTemplate> </asp:DeclarativeCatalogPart> </ZoneTemplate> </asp:CatalogZone>
The controls inside the DeclarativeCatalogPart control will be available to the end user when the page is viewed in catalog mode.