How to Create WebPartManager Control in code

The WebPartManager Control

The WebPartManager control acts like a centralized hub that manages all the other Web Parts controls on a Web page. This control coordinates the interaction between Web Parts and Web Parts zone. The WebPartManager control manages the personalization states of Web Parts controls on a Web page. Personalization allows storing of User information and all the runtime customization (defined by the user) in a persistent storage (typically SQLServer database). These customizations are loaded when the user visits the website the next time. If you create a Web page that uses Web Parts controls, ensure that the page contains a WebPartManager control . There must be only one intance of the WebPartManager control on each Web page that uses the control, and it must be placed before other Web Parts Zone controls are placed on the Web page. The WebPartManager control is an object of the WebPartManager class.

The WebPartManager control performs the following tasks to control the functionality of a Web page.

  • Keeping track of different controls on a Web page.
  • Inserting and removing controls on a Web page 
  • Establishing , monitoring and managing connections between various Web Parts controls.
  • Enabling you to customize the appearance of a Web page by dragging various controls to different locations on the page.
  • Providing various views , Which you can use to change and personalize the properties and behavior of controls.
  • Enabling you to toggle between different views of a Web Page , Thereby simplifying certain tasks, such as modifying layout and editing controls.

Using the WebPartManager Class

The WebPartManager class allows users to toggle between various display modes . These display modes help the user to perform different actions on the Web page, such as changing the layout of a Web page or editing controls, and the rest. The WebPartManager class has the following five display modes:
BrowseDisplayMode- Specifies the default display mode for pages that contain Web Parts controls.
CatalogDisplayMode-Specifies the display mode in which a catalog of controls is visible . A user can add controls to a Web page from the catalog.
ConnectDisplayMode- Represents the display mode in which the connection UI is visible and where users can manage the connections between the controls of Web page.
DesignDisplayMode- Represents the display mode in which the user can modify the layout of a Web page.
EditDisplayMode- Specifies the display mode in which the user can change the appearance , properties and behavior of server controls.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Createwebpart.aspx.cs" Inherits="Createwebpart" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:Button ID="Button1" runat="server" Text="Create web part" OnClick="Button1_Click" />

        <br />
        <asp:Label ID="Label1" runat="server"></asp:Label>


How to Create WebPartManager Control in code


Popular posts from this blog

difference between structure and union in C Language

Difference between Linear search and Binary Search in c language

Difference between static and dynamic websites