Link to home
Start Free TrialLog in
Avatar of minglelinch
minglelinch

asked on

Click Event for telerik:RadMenuItem

I need to do something while clicking a telerik:RadMenuItem. It seems that there's no event like onclick for telerik:RadMenuItem. I used OnClientItemClicking in the following link:
http://www.telerik.com/help/aspnet-ajax/menu_clientsideonclientitemclicking.html
but I got OnClientItemClicking is not a valid attribute for element RadMenuItem.

How can I achieve it? Thanks.
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

"but I got OnClientItemClicking is not a valid attribute for element RadMenuItem" you can ignore this error. it's actaully just Visual Studio not recognising the telerik attributes. it wont affect your compiling, in fact, that problem should go away if you sometimes compile or reload the project.
you can also handle the menuclick events on the server side: http://www.telerik.com/help/aspnet-ajax/menu-server-side-item-click.html

for testing purposes.. you can also just add an alert to the onClicking javascript function... something like...
function onClicking(sender, eventArgs)
{
    alert('A menu item has been clicked');

Open in new window

Just as a quick test to satisfy yourself that things are working as they should.
I am also in for MlandaT's example.
Avatar of minglelinch
minglelinch

ASKER

I tried ItemClick event and server function, and
    protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
    {
        Telerik.Web.UI.RadMenuItem ItemClicked = e.Item;
    }
The type or namespace 'RadMenuEventArgs' could not be found.

I tried OnClientItemClicking event with javascript function
        function Logoff_ItemClick(sender, eventArgs)
        {
            alert('A menu item has been clicked');
        }
The alert does not popup, nothing happens while clicking ... RadMenuItem is defined below -
<telerik:RadMenuItem Text="LOGOFF" OnClientItemClicking="Logoff_ItemClick" ></telerik:RadMenuItem>        

From http://www.telerik.com/help/aspnet-ajax/menu-client-side-events.html, OnClientItemClicking is set at RadMenu, not RadMenuItem. How can make click event on RadMenuItem ?

Thanks.    
I just set OnClientItemClicking="Logoff_ItemClick" at RadMenu level, it works. The alert message popped up. Thanks for help.
Still Not Right...

 The alert message popup wheneve I clicked any menuitem. I only need to handle Logoff menuitem.
Please help ...
ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can even add custom attributes and use them to modify the behaviour in the OnClientItemClicking handler http://www.telerik.com/help/aspnet-ajax/menu-items-custom-attributes.html
Thanks for help. I made it work.

            var item = eventArgs.get_item();
            var txt = item.get_text();
            if (txt == "LOGOFF") {
                     ... ...
            }