[CLOSED] Create Panel w/MenuPanel at Page_Load in code behind

  1. #1

    [CLOSED] Create Panel w/MenuPanel at Page_Load in code behind

    Hello,
    I've been through a bunch of posts and tried a lot of different things and I can't for the life of my figure this out. In Page_Load in code behind I am creating a Panel and inside the panel I am creating a MenuPanel, and then the Panel is added to the PlaceHolder. The Panel gets rendered, but for some reason the MenuPanel is not showing up. Please look at my code below and let me know what I'm missing here, I'm using V2.5.1, thanks!


    <%@ Page Language="C#"%>
    <%@ Register Assembly="Ext.NET" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        
        protected void Page_Load(object sender, EventArgs e)
        {
            Ext.Net.Panel dynPanel = new Ext.Net.Panel()
            {
                Title = "My Menu",
                Height = 400,
                Width = 200,
                Collapsible = false,
                MarginSpec = "20 0 0 20"
            };
            Ext.Net.MenuPanel menuPanel1 = new MenuPanel();
            Ext.Net.Menu menu = new Ext.Net.Menu()
            {
                ShowSeparator = false,
            };
            Ext.Net.MenuItem menuItem;
            for (int i = 1; i < 5; i++)
            {
                menuItem = new Ext.Net.MenuItem()
                {
                    ID = "Menu_" + i.ToString(),
                    Text = "Menu" + i.ToString()
                };
                menu.Items.Add(menuItem);
            }
            menuPanel1.Add(menu);
            dynPanel.Items.Add(menuPanel1);
            this.myPlaceHolder.Controls.Add(dynPanel);
        }
    </script>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="ExtResourceManager" runat="server" DisableViewState="false" RenderStyles="Embedded" />
            <asp:PlaceHolder ID="myPlaceHolder" runat="server"></asp:PlaceHolder>
    </body>
    </html>
    JW
    Last edited by Daniil; Oct 24, 2014 at 4:27 PM. Reason: [CLOSED]
  2. #2
    Hi @jwhitmire36,

    There are two things.

    1. The MenuPanel has no height. I would set a FitLayout for the outer Panel.

    2. You should put MenuItems directly to a MenuPanel's Menu. No interim Menu is required.

    Example
    protected void Page_Load(object sender, EventArgs e)
    {
        Ext.Net.Panel dynPanel = new Ext.Net.Panel()
        {
            Title = "My Menu",
            Height = 400,
            Width = 200,
            Collapsible = false,
            MarginSpec = "20 0 0 20",
            Layout = "fit"
        };
        Ext.Net.MenuPanel menuPanel1 = new MenuPanel();
        menuPanel1.Menu.ShowSeparator = false;
        Ext.Net.MenuItem menuItem;
        for (int i = 1; i < 5; i++)
        {
            menuItem = new Ext.Net.MenuItem()
            {
                ID = "Menu_" + i.ToString(),
                Text = "Menu" + i.ToString()
            };
            menuPanel1.Menu.Items.Add(menuItem);
        }
        dynPanel.Items.Add(menuPanel1);
        this.myPlaceHolder.Controls.Add(dynPanel);
    }
  3. #3
    Got it, thanks. I figured it would be something fairly basic I was overlooking. You can close this thread.

    Appreciate the help.
    JW

Similar Threads

  1. programatically create menu from code behind file
    By Wayne Fitzgerald in forum 2.x Help
    Replies: 2
    Last Post: Oct 31, 2012, 11:59 AM
  2. Replies: 0
    Last Post: Nov 01, 2011, 2:06 PM
  3. Create Grid Panel Editor in Code Behind
    By mkshields9w57 in forum 1.x Help
    Replies: 2
    Last Post: Aug 11, 2011, 4:27 PM
  4. [CLOSED] How to Create a Menu in Code
    By 78fede78 in forum 1.x Premium Help
    Replies: 3
    Last Post: Oct 19, 2010, 5:36 PM
  5. Replies: 3
    Last Post: Dec 12, 2008, 11:04 AM

Tags for this Thread

Posting Permissions