[CLOSED] Dynamic created MenuItems and directEvents
Releated to the following topic Disable a MenuItem when button selected I began to add click directevents so that the server could load new data into the grid, but I received the following error:
Quote:
The control with ID 'CfdbVer24' not found.
Below is a seqment of the code:
Code:
...
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Icon="Database" >
<Menu>
<ext:Menu ID="CfdbOptionsMenu" runat="server">
<%-- MenuItems dynamically create in behind code --%>
</Menu>
</ext:Button>
<ext:Label ID="CfdbVersionTitle" runat="server" />
</Items>
</ext:Toolbar>
</TopBar>
...
Code:
protected void Page_Load(object sender, EventArgs e) {
if (!X.IsAjaxRequest) {
CFVDataContext dc = new CFVDataContext;
// Retrieve all available versions that can be selected.
var q = from c in dc.CfdbVersions
where c.IsActive == true
orderby c.Order descending
select c;
// Create the menu items
foreach (var c in q)
{
Ext.Net.MenuItems item = new Ext.Net.MenuItems() {
ID = "CfdbVer" + c.CfdbVer.ToString(),
Text = c.Description,
Icon = Icon.Database
};
item.DirectEvents.Click.Event += SelectCfdbVersion;
Ext.Net.Parameter prmVer = new Ext.Net.Parameter() {
Name = "Version",
Value = c.CfdbVer.ToString(),
Mode = Parameter.Value
}
item.DirectEvents.Click.ExtraParams.Add(prmVer);
Ext.Net.Parameter prmDesc = new Ext.Net.Parameter() {
Name = "Description",
Value = c.Description,
Mode = Parameter.Value
}
item.DirectEvents.Click.ExtraParams.Add(prmDesc);
item.addTo(CfdbOptionsMenu);
}
}
}
Code:
protected void SelectCfdbVersion (object sender, DirectEventArgs e)
{
string Description = e.ExtraParams["Description"];
string version = e.ExtraParams["Version"];
}
I found the following thread Gridpanel Directevent in code behind and removed the test of "if (!X.IsAjaxRequest) { }" from the Page_Load method and I am still having an issue.
Do you have any additional suggestions or examples.