Hello Dear
I want to do some stuff in javascript when the user clicks an MenuItem;
As in the IG-Documentation, I use the following javascript function;
function TopMenuClick(MenuId, ItemId) { if (itemId == "mnuID") { } }
In markup declared via;
<MenuClientSideEvents ItemClick="TopMenuClick()"/>
But ItemID and MenuID is always 'undefined' when the javascript function get hit, don't know why "MenuID" is undefined but for the Items I never set anything like a "ClientID" or a "ID" --> So I can understand that this is undefined in Javascript.
Can you tell me if Im doing something wrong, or where I can set the clientID and how to read it via javascript?
Thx
8.3.20083.2059
Hello,
You just need to remove the braces from clientside event declaration.
Change ths line:
into this:
<MenuClientSideEvents ItemClick="TopMenuClick"/>(without braces).
Thanks for your answer, strange but worked.
Do you have another tip how I can set the ClientID of MenuItems (I see "menu" for the menu and "menu_1" for the sender in my javascript debugging console).
thanks again
Hello again,
it is not strange. ClientEvents object is expecting event handler. When you set the value of "TopMenuClick", you are passing a reference to that function. But when you set the value of "TopMenuClick()" you are actually performing a call to TopMenuClick without any arguments.
About your other question - you cannot set clientID of menu item.
Hi again,
if you need to distinguish items on client side, you may use Tag property (
You may check out Client API docs:
to find out what properties will be bes suitable for you.ClientID is only property for a Menu, which is a control, but not MenuItem, which is part of complex control. That's why there is no ClientID for MenuItem elements. Also ClientID property is programatically set by the ASP.NET engine for all controls of a page. It is not something that is controlled by developer (either developer of a component, or deveoper of a site using components). It is baed on the "ID" property of the control. Sometimes it is the same, but it is not neccessary always that situation. It can be obtained on the client using some Server Tag syntax:
<%= UltraWebMenu1.ClientID %>
Assuing we have set the ID proerty of control to "UltraWebMenu1". To avoid calls like this within client-side event handler, we send down this property. Documentation about client side events:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/WebMenu_Client_Side_Events_CSOM.html
And here the utility functions are described:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/WebMenu_Utility_Functions_CSOM.html
These are functions to be used withing event handler (or outside) to obtain a reference to client-side objects of a Menu.
Any Idea? Im miss-using the "AccessKey" property to have an Identifier, think this is not best practise?
Anton Staykov"] About your other question - you cannot set clientID of menu item.
If this statement is true (I just would like to use something that acts as ID in the javascript of the client site);
Can I assume that this ID is always the same? "Menu_1" looks generated and I don't want to have the risk that this ID changes somehow...