We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Click Event for telerik:RadMenuItem

minglelinch
minglelinch asked
on
Medium Priority
3,412 Views
Last Modified: 2012-05-11
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.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
"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.
CERTIFIED EXPERT

Commented:
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.

Commented:
I am also in for MlandaT's example.

Author

Commented:
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.    

Author

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

Author

Commented:
Still Not Right...

 The alert message popup wheneve I clicked any menuitem. I only need to handle Logoff menuitem.
Please help ...
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
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

Author

Commented:
Thanks for help. I made it work.

            var item = eventArgs.get_item();
            var txt = item.get_text();
            if (txt == "LOGOFF") {
                     ... ...
            }
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.