Onlineatoz.net | ToolBox WepParts Control ImportCatalogPart

ToolBox WepParts Control ImportCatalogPart

ImportCatalogPart Web Server Control

in ASP.NET environment,This article describes you how to work with ImportCatalogPart Web Control.The goal of the ImportCatalogPart Web server control is to imports a description file for a WebPart control or any other server control.

By using ImportCatalogPart control,an user can add a control at the runtime into the web page. The description file enables users to share settings for WebPart controls.It is an XML file that that contains name/value pairs which describes the state of the control.After imports a description file, the WebPart control referenced in the file appears within the ImportCatalogPart control and a user can add the control to the page.

ImportCatalogPart control using with Web Parts controls

It can be compiled into an assembly or it can be a .ascx file for these purposes . In either case, the control must be referenced in an imported description file that exist on the Web server containing the hosting page.The ImportCatalogPart control can only at visible stage When a user switches the page to catalog display mode.

For exporting a Description file for a control, which meets the following,

  • The control has properties marked with the Personalizable attribute.
  • The Web.config file has the enableExport attribute value set to true in the element.
  • You have set the value of the ExportMode property on the control to a value other than the default value of None, which prohibits export.
Setting an ImportCatalogPart Web Server Control

For displaying an ImportCatalogPart Web server control run time , It requires a Web Parts page is in edit mode, and when the user has selected an associated WebPart control for editing.

the following code snippets demonstrates how to work with the ImportCatalogPart Control

in .aspx.cs page,

protected void Button1_Click(object sender, EventArgs e)
{
wp1.DisplayMode = WebPartManager.BrowseDisplayMode;
}

protected void Button2_Click(object sender, EventArgs e)
{
wp1.DisplayMode = WebPartManager.CatalogDisplayMode;
}

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "Scope is: "
+ wp1.Personalization.Scope.ToString();
}

in .aspx page,

<html  >
<head id="head1" runat="server">
<title>Example</title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:WebPartManager ID="wp1" runat="server">
<Personalization InitialScope="Shared" Enabled="True" />
</asp:WebPartManager>

<asp:WebPartZone ID="WebPartZone1" runat="server"
EmptyZoneText="No parts to show.">
<ZoneTemplate>
</ZoneTemplate>
<CloseVerb Text="Close This Part" />
<MinimizeVerb Text="Minimize This Part" />
<EditVerb Text="Edit This Part" />
</asp:WebPartZone>

<asp:CatalogZone ID="CatalogZone1" runat="server" >
<ZoneTemplate>
<asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
<asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1"
runat="server">
<WebPartsTemplate>
<asp:Calendar id="Calendar1" runat="server" />
<asp:CreateUserWizard ID="CreateUserWizard1"
runat="server" />
</WebPartsTemplate>
</asp:DeclarativeCatalogPart>
<asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server"/>
</ZoneTemplate>
</asp:CatalogZone>

<hr />
<asp:Button ID="Button1" runat="server"
Text="Browse Mode" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server"
Text="Catalog Mode" OnClick="Button2_Click" /><br />
<asp:Label ID="Label1" runat="server" Text="" />
</div>
</form>
</body>
</html>
 
Related Links

Posted by: Admin
Posted on: 9/13/2011 at 6:55 AM
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed