Welcome Guest Search | Active Topics | Sign In | Register

ItemClick event handler problem w/dynamically created menu items. Options
Massis
Posted: Saturday, December 8, 2007 2:34:17 PM
Rank: Newbie
Groups: Member

Joined: 12/5/2007
Posts: 9
I'd appreciate your help with the follwoing.

I've dragged a menu control (mnuTemplate) onto my page, and I'm trying to dynamically add menu items to the control. Adding the menu items seems to work fine, however, the ItemClick event handler isn't firing when I click on the dynamically added items. Please see sample code code Ibelow.


Code: C#
protected void Page_Load(object sender, EventArgs e)
{
   EO.Web.MenuItem oInitMenuItem = new EO.Web.MenuItem("Test");
   mnuTemplate.Items.Add(oInitMenuItem);

   mnuTemplate.ItemClick += new EO.Web.NavigationItemEventHandler(mnuTemplate_ItemClick);
   oInitMenuItem.RaisesServerEvent = EO.Web.NullableBool.True;
   oInitMenuItem.NavigateUrl = "CfgMenuStruct.aspx";
}

protected void mnuTemplate_ItemClick(object sender, EO.Web.NavigationItemEventArgs e)
{
   EO.Web.MenuItem oItem = (EO.Web.MenuItem) e.NavigationItem;
   txtLabel.Text = oItem.Text.ToString();
}


Please respond to massis@sagestream.com ASAP if you have any comments/suggestions.

Thanks,
Massis

eo_support
Posted: Saturday, December 8, 2007 2:42:42 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

Try to set the menu's RaisesServerEvent to true. The menu will fire ItemClick event only when RaisesServerEvent is true. Also make sure that you clear NavigateUrl, server event works by posting back to the same page, NavigateUrl brings the browser to another page. So they don't work together.

Thanks
Massis
Posted: Sunday, December 9, 2007 11:56:24 AM
Rank: Newbie
Groups: Member

Joined: 12/5/2007
Posts: 9
Clearing the NavigateUrl as you suggested resolved the problem.

Thanks,
Massis


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.