using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.Linq;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //**********  Creae Menu **********
        if (!this.IsPostBack)
        {
            MenuItem Root = new MenuItem("Select Mode");

            foreach (WebPartDisplayMode mode in MyPartManager.DisplayModes)
            {
                if (mode.IsEnabled(MyPartManager))
                {
                    Root.ChildItems.Add(new MenuItem(mode.Name));
                }
            }

            PartsMenu.Items.Add(Root);
        }
        //******************** Create Title ************
        if (!this.IsPostBack)
        {
            int i = 1;
            foreach (WebPart part in MyPartManager.WebParts)
            {
                if (part is GenericWebPart)
                {
                    part.Title = string.Format("Web Part Nr. {0}", i);
                    i++;
                }
            }
        }



    }
    protected void PartsMenu_MenuItemClick(object sender, MenuEventArgs e)
    {
          MyPartManager.DisplayMode = MyPartManager.DisplayModes[e.Item.Text];

    }
    protected void MyCalendar_Load1(object sender, EventArgs e)
    {
        GenericWebPart part = (GenericWebPart)MyCalendar.Parent;
        part.AllowClose = false;
        part.HelpMode = WebPartHelpMode.Modeless;
        part.HelpUrl = "CalendarHelp.htm"; 
    }

}
