This is a migrated thread and some comments may be shown as answers.
Cancel Menu Postback Clientside
3 Answers 149 Views
This is a migrated thread and some comments may be shown as answers.
Robert Verderber
Top achievements
Rank 2
Robert Verderber asked on 02 Apr 2008, 05:27 PM
Is there a way to cancel the click on a menu item in the OnClientItemClicked event?

The documentation says you can by returning a false from the handler but I can seem to get it to work.

Here is a routine i wrote to cancel the postback if the user hits the cancel button on the confirm window 

function RADItemClicked(sender, eventArgs)
{
    var item = eventArgs.get_item();
    if(item.get_text()=="Save Changes") {
        if (!confirm("Save Changes?")) { return false }
    }
   
}

Not sure what im doing wrong. Any advise would be appreciated.

TIA

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 03 Apr 2008, 07:22 AM
Hello Robert Verderber,

I suggest that you subscribe to the OnClientItemClicking event. In its event handler you can check the text of the clicked item and use set_cancel(true) to cancel the event.

Here is how your event handler can be defined:

function onClientItemClicking(sender, eventArgs)  
{  
    var item = eventArgs.get_item();  
    if(item.get_text()== "Save Changes") {  
        if (!confirm("Save Changes?")) { eventArgs.set_cancel(true); }  
    }  

<telerik:RadMenu ID="RadMenu1"   
                runat="server"   
                OnClientItemClicking="onClientItemClicking"

I hope this helps.

Kind regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Michael Dosen
Top achievements
Rank 1
answered on 17 Dec 2010, 03:52 AM
why return false did not work! I have it working with your fix.
0
Helen
Telerik team
answered on 17 Dec 2010, 02:16 PM
Hi,

It works for the asp.net classic RadMenu version.

Kind regards,
Helen
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Menu
Asked by
Robert Verderber
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Michael Dosen
Top achievements
Rank 1
Helen
Telerik team
Share this question
or