ToolBox WepParts Control WebPartManager

WebPartManager Web Server Control

in ASP.NET environment,This article describes you how to work with WebPartManager Web Control.In DOT.Net environment, The WebPartManager control can serve as the hub or control center of a Web Parts application.In every page, There must be one--and only one--WebPartManager control instance that uses Web Parts controls. But an authenticted user only access the most aspects of Web Parts applications, the WebPartManager control works only with authenticated users.

Moreover, server controls only can working with its functionality that reside within Web Parts zones that inherit from the WebZone class. Server controls that reside on a page outside of these zones can have very little Web Parts functionality or interaction with the WebPartManager control.

WebPartManager's Tasks
  • Tracking Web Parts controls -Keeps track of the many different kinds of controls on a page that provide Web Parts features, including WebPart controls, connections, zones, and others.
  • Adding and removing Web Parts controls -Provides the methods for adding, deleting, and closing WebPart controls on a page.
  • Administering connections -Creates connections between controls, and monitors the connections as well as the processes of adding and removing them.
  • Personalizing controls and pages -Enables users to move controls to different locations on a page, and launches the views in which users can edit the appearance, properties, and behavior of controls. Maintains user-specific personalization settings on each page.
  • Toggling between different page views -Switches a page among different specialized views of the page, so that users can carry out certain tasks such as changing page layout or editing controls.
  • Raising Web Parts life-cycle events -Defines, raises, and enables developers to handle life-cycle events of Web Parts controls, such as when controls are being added, moved, connected, or deleted.
  • Enabling import and export of controls -Exports XML streams that contain the state of the properties of WebPart controls, and allows users to import the files for convenience in personalizing complex controls in other pages or sites.
WebPartManager's Fields Vs Display modes
  • BrowseDisplayMode - The normal user view of a Web page; the default and most common display mode.
  • DesignDisplayMode -The view in which users can rearrange or delete controls to change the page layout.
  • EditDisplayMode - The view in which an editing user interface (UI) becomes visible; users can edit the appearance, properties, and behavior of the controls that are visible in the normal browse mode.
  • CatalogDisplayMode -Enables users to move controls to different locations on a page, and launches the views in which users can edit the appearance, properties, and behavior of controls. Maintains user-specific personalization settings on each page.
  • ConnectDisplayMode -The view in which a connection UI becomes visible; users can connect, manage, or disconnect connections between controls.
Events
  • AuthorizeWebPart -Occurs just before a control is added to a page to verify that it is authorized.
  • ConnectionsActivated -Occurs after all the connections on a page have been activated.
  • ConnectionsActivating - Occurs just before the process of activating all the connections on a page.
  • DisplayModeChanged -Occurs after the current display mode of a page has changed.
  • DisplayModeChanging -Occurs just before the process of changing a page's display mode.
  • AuthorizeWebPart -Occurs just before a control is added to a page to verify that it is authorized.
  • ConnectionsActivated -Occurs after all the connections on a page have been activated.
  • ConnectionsActivating - Occurs just before the process of activating all the connections on a page.
  • DisplayModeChanged -Occurs after the current display mode of a page has changed.
  • DisplayModeChanging -Occurs just before the process of changing a page's display mode.
  • SelectedWebPartChanged -Occurs after the selection of a control has been canceled.
  • SelectedWebPartChanging -Occurs just before the process of canceling the selection of a control.
  • WebPartAdded -Occurs after a control has been added to a zone.
  • WebPartAdding -Occurs just before the process of adding a control to a zone.
  • WebPartClosed -Occurs after a control has been closed
  • WebPartClosing -Occurs just before the process of closing a control.
  • WebPartDeleted -Occurs after an instance of a dynamic control (one that was created programmatically or added from a catalog) has been permanently deleted.
  • WebPartDeleting -Occurs just before the process of deleting a dynamic control.
  • WebPartMoved -Occurs after a control has moved within its zone or to another zone.
  • WebPartMoving -Occurs just before the process of moving a control.
  • WebPartsConnected -Occurs after two controls selected for participation in a connection have established the connection.
  • WebPartsConnecting -Occurs just before the process of connecting two controls.
  • WebPartsDisconnected -Occurs after two connected controls have been disconnected.
  • WebPartsDisconnecting -Occurs just before the process of disconnecting two controls.

The following code snippets explains you the WebPartManager control

in .aspx.cs page,

  WebPartManager _manager;

  void Page_Init(object sender, EventArgs e)
  {
    Page.InitComplete += new EventHandler(InitComplete);
  }  

  void InitComplete(object sender, System.EventArgs e)
  {
    _manager = WebPartManager.GetCurrentWebPartManager(Page);

    String browseModeName = WebPartManager.BrowseDisplayMode.Name;
    
    foreach (WebPartDisplayMode mode in _manager.SupportedDisplayModes)
    {
      String modeName = mode.Name;      
      if (mode.IsEnabled(_manager))
      {
        ListItem item = new ListItem(modeName, modeName);
        DisplayModeDropdown.Items.Add(item);
      }
    }
   
    if (_manager.Personalization.CanEnterSharedScope)
    {
      Panel2.Visible = true;
      if (_manager.Personalization.Scope == PersonalizationScope.User)
        RadioButton1.Checked = true;
      else
        RadioButton2.Checked = true;
    }
    
  } 
  
  void DisplayModeDropdown_SelectedIndexChanged(object sender, EventArgs e)
  {
    String selectedMode = DisplayModeDropdown.SelectedValue;

    WebPartDisplayMode mode = _manager.SupportedDisplayModes[selectedMode];
    if (mode != null)
      _manager.DisplayMode = mode;
  }
  
  void Page_PreRender(object sender, EventArgs e)
  {
    ListItemCollection items = DisplayModeDropdown.Items;
    int selectedIndex = 
      items.IndexOf(items.FindByText(_manager.DisplayMode.Name));
    DisplayModeDropdown.SelectedIndex = selectedIndex;
  }
 
  protected void LinkButton1_Click(object sender, EventArgs e)
  {
    _manager.Personalization.ResetPersonalizationState();
  }
 
  protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
  {
    if (_manager.Personalization.Scope == PersonalizationScope.Shared)
      _manager.Personalization.ToggleScope();
  }
  
  protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
  {
    if (_manager.Personalization.CanEnterSharedScope && 
        _manager.Personalization.Scope == PersonalizationScope.User)
      _manager.Personalization.ToggleScope();
  }
        

in .aspx page,

<asp:Panel ID="Panel1" runat="server" 
    Borderwidth="1" 
    Width="230" 
    BackColor="lightgray"
    Font-Names="Arial" >
    <asp:Label ID="Label1" runat="server" 
      Text=" Display Mode" 
      Font-Bold="true"
      Font-Size="8"
      Width="120" />
    <asp:DropDownList ID="DisplayModeDropdown" runat="server"  
      AutoPostBack="true" 
      Width="120"
      OnSelectedIndexChanged="DisplayModeDropdown_SelectedIndexChanged" />
    <asp:LinkButton ID="LinkButton1" runat="server"
      Text="Reset User State" 
      ToolTip="Reset the current user's personalization data for the page."
      Font-Size="8" 
      OnClick="LinkButton1_Click" />
    <asp:Panel ID="Panel2" runat="server" 
      GroupingText="Personalization Scope"
      Font-Bold="true"
      Font-Size="8" 
      Visible="false" >
      <asp:RadioButton ID="RadioButton1" runat="server" 
        Text="User" 
        AutoPostBack="true"
        GroupName="Scope" OnCheckedChanged="RadioButton1_CheckedChanged" />
      <asp:RadioButton ID="RadioButton2" runat="server" 
        Text="Shared" 
        AutoPostBack="true"
        GroupName="Scope" 
        OnCheckedChanged="RadioButton2_CheckedChanged" />
    </asp:Panel>
  </asp:Panel>
                    
                    
 
Related Links

Posted by: Admin
Posted on: 9/17/2009 at 5:13 PM
Tags: , ,
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (30) | Post RSSRSS comment feed

Comments

Onlineatoz.net

Thursday, September 17, 2009 5:17 PM

trackback

ToolBox WepParts Control WebPartZone

ToolBox WepParts Control WebPartZone

cash today United States

Thursday, January 21, 2010 6:09 PM

cash today

thanks again

payday loans United States

Saturday, April 10, 2010 12:34 PM

payday loans

You will get all you want in life if you help enough other people get what they want.

discovery life United States

Sunday, April 18, 2010 2:42 PM

discovery life

Great post! Thanks for the information

Rapidshare United States

Tuesday, April 27, 2010 10:58 PM

Rapidshare

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

personal cash loans United States

Tuesday, May 04, 2010 3:24 PM

personal cash loans

One of the best uses of your time is to increase your competence in your key result areas.

Terry Qatar

Saturday, May 22, 2010 4:24 AM

Terry

Do you have a spam problem on this blog; I also use Blog Engine, and I was speculating about your experiences; we have developed some great techniques and we are looking to exchange practices with others, please Email me if interested.

mac fonts United States

Monday, June 07, 2010 1:48 PM

mac fonts

I was very pleased to find this site. I wanted to thank you for this great read!! This is a very informative post, it helps me more.

faxless cash advance United States

Thursday, June 10, 2010 10:43 AM

faxless cash advance

Give yourself something to work toward - constantly.

Svitlana.Net.Ua United States

Wednesday, June 16, 2010 5:08 PM

Svitlana.Net.Ua

I would like to thank you for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now.

няня United States

Saturday, June 19, 2010 11:48 AM

няня

I would like to thank you for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now.
http://svitlana.net.ua/staff/category/3/ гувернантка, http://svitlana.net.ua/staff/category/5/ повар, http://svitlana.net.ua/staff/category/6/ садовник, http://svitlana.net.ua/staff/category/10/ репетитор, http://svitlana.net.ua/staff/category/4 домработница, http://svitlana.net.ua/staff/category/8/ семейная пара, http://svitlana.net.ua/pages/2/ работа няней.

walking shoes People's Republic of China

Monday, June 21, 2010 7:13 AM

walking shoes

Because of life rhythm accelerated and working pressure increased so that people to pursue a relaxed, carefree mood in the spare time.They won’t suffer trend while seeking a comfortable, natural new packing. Just introduce some websites for you about natural new packinghttp://www.mbt-outlet-store.com/mbt-men-shoes.html

Онлайн Покер United States

Thursday, June 24, 2010 10:53 PM

Онлайн Покер

You got numerous positive points there. I made a search on the issue and found nearly all peoples will agree with your blog.

reviews about online jobs United States

Wednesday, June 30, 2010 2:10 AM

reviews about online jobs

That is a awesome tiny demi-lune, appropriate dimension for the area it’s in. I really don't know regarding how it fits together with your other furniture, but by alone it looks really good there. Fantastic job!

Каталог проституток United States

Sunday, July 04, 2010 12:55 AM

Каталог проституток

Но, мы со всеми из них уже знакомы и поддерживаем дружеские отношения уже много лет, поэтому, никогда не возникает проблем с тем, что бы уединиться. Они тоже ищут места, где можно спрятаться, поэтому на всем протяжении отдыха мы практически не пересекаемся, только по особой надобности, но, такие надобности возникают не часто.

Магазин сантехники United States

Sunday, July 04, 2010 1:43 AM

Магазин сантехники

You have some honest ideas here. I done a research on the issue and discovered most peoples will agree with your blog.

the ultimate cellulite treatment in a book. United States

Monday, July 05, 2010 12:03 PM

the ultimate cellulite treatment in a book.

Some distinct solutions are liposuction  fat lotions  pills  massages and then there's even Preparation H  Some persons say they could use it to relieve the level of fat that appears on several components of their entire body  Even so it does ought to be the Canadian version of preparation H and not

проститутка в Москве United States

Wednesday, July 07, 2010 12:26 AM

проститутка в Москве

You got numerous positive points there. I made a search on the issue and found nearly all peoples will agree with your blog.

Новинки сантехники United States

Saturday, July 10, 2010 11:04 PM

Новинки сантехники

Can you please provide more information on this subject? BTW your blog is great. Cheers.

Проститутки United States

Sunday, July 11, 2010 10:51 PM

Проститутки

You gave nice ideas here. I done a research on the issue and learnt most peoples will agree with your blog. Certainly, these practices are unfair; but they say that most of their rules are only to apply to people who overdraw.

losing weight after pregnancy fast United States

Wednesday, July 14, 2010 3:44 PM

losing weight after pregnancy fast

Suggested food items to meet your day-to-day nutritional ambitions Use the nutritional specifications uncovered at   to aid you take much better each working day  Visit this internet site to discover your individual nutritional recommendations dependent in your age  gender and degree of physical activity    Its effortless  fast and informative  These tailored rules will advise how several servings of every foods team are encouraged to preserve a nicely well balanced eating habits    

losing weight after pregnancy while breastfeeding United States

Wednesday, July 14, 2010 11:04 PM

losing weight after pregnancy while breastfeeding

Needed Duration for Pounds the loss immediately after Pregnancy to Regain the Form The duration of bodyweight burning depends upon how a great deal excess weight you gained throughout your pregnancy  The typical excess weight acquire in most females is just about 25 to 35 kilos  out of which 12 to 14 fat is normally shed though delivery leaving behind 12 to 21 fat of bodyweight  These 12 to 21 weight can very easily be dropped inside of 6 to 8 weeks following the 1st three or more weeks of recovery  So when you gained 50 lbs then it'll consider around ten weeks to regain your pre-pregnancy form  On the other hand  this can be just an example so don't acquire these figures as well factually

easy way to reduce weight United States

Thursday, July 15, 2010 4:25 AM

easy way to reduce weight

Cancer prevention inhibition  antioxidant applications  excess weight handle  anti-inflammatory and anti-microbial properties have all been researched to some degree  Some reports indicate green tea herb might have the capacity to support stop particular cancers from developing  Green tea herb consists of chemicals regarded as polyphenols  which have antioxidant properties  An antioxidant can be a compound that blocks the action of activated oxygen molecules  acknowledged as totally free radicals  that will destruction cells   Origins and Background

Supra Vaider High People's Republic of China

Saturday, July 17, 2010 8:21 AM

Supra Vaider High

Good page. It's useful to study your blog. The information of your site is precisely excellent, and your blog design is Simple good. Also you can look me at http://www.supras.cc/supra-vaider-high-3/ and give some suggestion. Thanks.

air jordan 3 People's Republic of China

Tuesday, July 20, 2010 8:03 AM

air jordan 3

I've been looking for a similar to this post. Not only extensively but also detailly. We can learn a lot from the post. I recommend to you , you can come communication in here. Let us grow up together.On the other hand ,I know some websites content is very well.you can go and see.Such as
www.chaneloutletstores.com


















































data matching United States

Tuesday, July 20, 2010 1:55 PM

data matching

I appreciate the work that you have put into this page. Genuinely good,and informative. Thank You

nfl jersey People's Republic of China

Friday, July 23, 2010 9:15 AM

nfl jersey

Thanks for the info!!

Toronto Condo Staging United States

Saturday, July 24, 2010 7:59 PM

Toronto Condo Staging

Server controls that reside on a page outside of these zones can have very little Web Parts functionality or interaction with the WebPartManager control.

Strip That Fat Greece

Wednesday, July 28, 2010 7:18 AM

Strip That Fat

Admiring the time and effort you put into your blog and detailed information you offer! I will bookmark your blog and have my children check up here often. Thumbs up!

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading