I have a menu with menuitems. Each menuitem click even points to a server side method that determines which menuitem was clicked and does the appropriate code block. I want to put a confirm dialog on the menus so that they have to confirm after they click any of the menuitems. I can do this easily with any control by adding this to the onclick event : onclick = "return myFunction()".
I cannot get this to work for the life of me with the new rad menu. Here's what I have so far:
this is the javascript to bring up the dialog based on the item clicked:
I think everything is ok with the javascript.
Here's the menu control:
Now with this, it does popup the confirm, but regardless if you hit OK or CANCEL it still runs the server method. I tried changing OnClientItemClicked = "return onClick():" but when i render the page it says Syntax Error.
Can someone please help me solve this? I'm assuming I'm missing something very simple
I cannot get this to work for the life of me with the new rad menu. Here's what I have so far:
this is the javascript to bring up the dialog based on the item clicked:
| function onClick(sender, eventArgs) { |
| var item = eventArgs.get_item(); |
| if (item.get_value() != "Action") { |
| switch (item.get_value()) |
| { |
| case "Export": |
| if (confirm("Are you sure you want to export the selected Employee's to Excel?") == true) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| break; |
| case "Terminate": |
| return confirm("Are you sure you want to Terminate the selected Employee's?"); |
| break; |
| } |
| } |
| } |
Here's the menu control:
| <telerik:RadMenu ID="RadMenu1" Width="100%" runat="server" |
| Skin="Web20" |
| OnClientItemClicked="onClick" |
| onitemclick="RadMenu1_ItemClick"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| <Items> |
| <telerik:RadMenuItem runat="server" PostBack="False" Text="Action" |
| Value="Action" ImageUrl="~/images/cog.png"> |
| <Items> |
| <telerik:RadMenuItem runat="server" Text="Export Selected" Value="Export"> |
| </telerik:RadMenuItem> |
| <telerik:RadMenuItem runat="server" Text="Term Selected" Value="Terminate"> |
| </telerik:RadMenuItem> |
| <telerik:RadMenuItem runat="server" Text="Import from Excel" Value="Import"> |
| </telerik:RadMenuItem> |
| </Items> |
| </telerik:RadMenuItem> |
| </Items> |
| </telerik:RadMenu> |
Now with this, it does popup the confirm, but regardless if you hit OK or CANCEL it still runs the server method. I tried changing OnClientItemClicked = "return onClick():" but when i render the page it says Syntax Error.
Can someone please help me solve this? I'm assuming I'm missing something very simple