My friend , it doesn't need a source file , i tell you to open a new solution add two or more menu items to a tool bar
inside the default.aspx.cs file try to override method "findControl (string id)" like the following
protected override FindControl ( string id)
{
return base.FindControl(id);
}
put a break point at the current method , then initialize the debug
once you click on any menu item , it will hang on to the current findcontrol method , then have a look at the id parameter value
it will always be "submitAjaxEventConfig" string value , whatever the control pressed was
here is a simplified .aspx source code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!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">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server">
</ext:ScriptManager>
<ext:Toolbar ID="MainToolBar" runat="server">
<Items>
<ext:ToolbarButton ID="Button1" runat="server" Text="File">
<Menu>
<ext:Menu>
<Items>
<ext:MenuItem ID="MenuItem1" runat="server" Text="Save As"></ext:MenuItem>
<ext:MenuItem ID="Menuitem2" runat="server" Text="Open"></ext:MenuItem>
</Items>
</ext:Menu>
</Menu>
</ext:ToolbarButton>
</Items>
</ext:Toolbar>
</form>
</body>
</html>
default.aspx.cs source code
using System;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public override Control FindControl(string id)
{
return base.FindControl(id);
}
}
now try to insert a break point in the beginning of the find control method .
try clicking any menu item in the internet explorer
now hover over the id parameter , you will find that its value is "submitAjaxEventConfig" value
whereas in normal scenario , it must bear the string value of the current clicked control's id
my question is , i need to get the value of menu item's id that was pressed .
if you attached an ajax method to the current items that are added to the current page , it will work just find
but what for the menu items that were loaded or created in memory from a data base and doesn't exist at all in the source code of the page but are fetched from the data base using recursion .
when you try to attach an ajax event for all the items , it calls findcontrol method first but it doesn't find the control it needs because the menus are created on the fly