View Full Version : [CLOSED] How to make MenuItem Clickable and call a Direct Method?

Jan 18, 2013, 3:53 PM
I am having trouble creating the "Click Event" on a MenuItem created dynamically from an XML file. The menuItems show up correctly on the screen but when I click on the menuItem, it is giving me the error message:
The control with ID 'id1f56fb29c2d1e820' not found

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MasterWithSusan.aspx.cs"
Inherits="MasterPageTest.MasterWithSusan" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script runat="server">
public string Items(Dictionary<string, string> parameters)
string tag = parameters["tag"];

List<Ext.Net.MenuItem> items = new List<Ext.Net.MenuItem>();

List<String> MenuList = CreateMenuItems(tag);
foreach (string menuitem in MenuList)
Ext.Net.MenuItem mi = new Ext.Net.MenuItem(menuitem) { Icon = Icon.ArrowRight, };
mi.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(mi_DirectC lick);
return ComponentLoader.ToConfig(items);

public List<String> CreateMenuItems(string masterMenu)
List<String> menuItemElements = new List<String>();
XDocument doc = XDocument.Load(@"C:\DATA\Projects\Test\MasterPageTest\MasterPageTes t\NewMenu.xml");

if (doc.Root == null) return null;
var mainMenus =
m => ((string)m.Attribute("ID") == masterMenu)).
Select(m => new
ID = (string)m.Attribute("ID"),
MenuName = (string)m.Attribute("MenuName"),
MenuItems = m.Element("MenuItems").Elements("MenuItem").Select(menuItem => (string)menuItem.Attribute("ItemName"))
foreach (var mainMenu in mainMenus)

return menuItemElements;


public void mi_DirectClick(object o, DirectEventArgs e)

<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Toolbar ID="Toolbar1" runat="server">
<ext:Button ID="Button1" runat="server" Text="Schedule">
<ext:Menu ID="Menu1" runat="server" TagString="Schedule">
<ext:MenuItem ID="MenuItem1" runat="server" IconCls="x-loading-indicator" Text="Loading..."
CanActivate="false" HideOnClick="false" />
<Loader Mode="Component" DirectMethod="#{DirectMethods}.Items" RemoveAll="true">
<ext:Parameter Name="tag" Value="this.tag" Mode="Raw" />

Below is the NewMenu.XML file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>


<MainMenu ID ="Schedule" MenuName="Schedules" Roles="Shipper" >
<MenuItem Id="1" ItemName="Trailer Schedule"/>
<MenuItem Id="2" ItemName="Custom Schedule"/>



Thank you in advance for your help.

Jan 19, 2013, 3:34 AM

In your case it's better to use DirectMethod, because you have to recreate dynamic controls, in your case MenuItems, on each request.

Some information you can read in this thread: http://forums.ext.net/showthread.php?12788-Issue-when-creating-Menuitems-dynamically