Jan 10, 2013, 5:42 AM
[CLOSED] Dynamic menu items in menu panel creation problem
i have implemented a Dynamic Menu panel in My Application
The Problem am Facing is on "Page_Load" the Menus will be created thats fine,
but during other operation in my application i need to add more menus to the menupanel,
and am calling the method "LoadMenu()" on button click "btnAddMoreMenu_click" and that regenerates the menus
and even it adds some new menu items to MenuPanel. but the Newly created menus are not reflected on the client side UI.
I want to achieve this with out refreshing the Page.
The Problem am Facing is on "Page_Load" the Menus will be created thats fine,
but during other operation in my application i need to add more menus to the menupanel,
and am calling the method "LoadMenu()" on button click "btnAddMoreMenu_click" and that regenerates the menus
and even it adds some new menu items to MenuPanel. but the Newly created menus are not reflected on the client side UI.
I want to achieve this with out refreshing the Page.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Question1.aspx.cs" Inherits="Question1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Question1</title>
<style type="text/css">
.x-menu.x-menu-horizontal .x-menu-list
{
overflow: hidden;
}
.x-menu.x-menu-horizontal .x-menu-list .x-menu-list-item
{
float: left;
}
.x-menu.x-menu-horizontal .x-menu-list .x-menu-list-item .x-menu-item-arrow
{
background: none;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport ID="ViewPort1" runat="server" Layout="FitLayout" AutoScroll="true">
<Items>
<ext:Panel ID="pnlTop" runat="server" Height="106"
BodyBorder="false" Border="false" Region="Center">
<Items>
<ext:MenuPanel ID="mPnlMain" runat="server" Border="false" Region="North" Height="30">
<Menu ID="mnuMain" runat="server" Hidden="false" ShowSeparator="true" EnableScrolling="false"
SubMenuAlign="tl-bl?" Cls="x-menu-horizontal" Floating="false">
</Menu>
</ext:MenuPanel>
<ext:Button ID="btnAddMoreMenu" runat="server" Text="Add More Menus">
<DirectEvents>
<Click OnEvent="btnAddMoreMenu_click" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ext.Net;
public partial class Question1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
LoadMenu();
}
public void LoadMenu()
{
Ext.Net.MenuItem mMenuItem = null;
for (int i = 0; i < 3; i++)
{
mMenuItem = new Ext.Net.MenuItem();
mMenuItem.ID = "Menu_" + i.ToString() + "_" + DateTime.Now.Minute.ToString();
mMenuItem.Text = "Menu_" + i.ToString() + "_" + DateTime.Now.Minute.ToString();
mMenuItem.Listeners.Click.Handler = "alert('" + mMenuItem.Text + "');";
mPnlMain.Menu.Items.Add(mMenuItem);
mMenuItem = null;
X.AddScript("mPnlMain.doLayout();");
}
}
protected void btnAddMoreMenu_click(object sender, DirectEventArgs e)
{
LoadMenu();
}
}
Last edited by Daniil; Jan 10, 2013 at 10:42 AM.
Reason: [CLOSED]