This is a migrated thread and some comments may be shown as answers.
RadContextMenu Cancel Postback from OnContextMenuClick javascript event
1 Answer 72 Views
This is a migrated thread and some comments may be shown as answers.
Tuhin Ghosh
Top achievements
Rank 1
Tuhin Ghosh asked on 19 Jul 2011, 10:28 AM
Hi,

I have created following context menu:

<telerik:RadContextMenu OnClientShowing="OnContextMenuShowing" OnClientItemClicked="OnContextMenuClick"
                  ID="RadMenu1" runat="server" OnItemClick="RadMenu1_ItemClick" EnableRoundedCorners="true"
                  EnableShadows="true">
                  <Items>
                    <telerik:RadMenuItem Text="Copy" />
                    <telerik:RadMenuItem Text="Cut" />
                    <telerik:RadMenuItem Text="Paste Above" />
                    <telerik:RadMenuItem Text="Paste Below" />
                  </Items>
                </telerik:RadContextMenu>


OnContextMenuClick I am writing some validation and I want to cancel the postback if validations fails, but its not happening.

I have searched everywhere but did not find any suitable answers for this , many places I found the following statement but it is not working 

args.set_cancel(true);

args in OnContextMenuClick does not have set_cancel method.

Also tried with return false; that too not worked.

Please help me by providing solutions its urgent.


Thanks & Regards

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 19 Jul 2011, 11:39 AM
Hello Tuhin,

You cannot cancel the OnClientItemClicked event so try the same in OnClientItemClicking and cancel the event.
Javascrupt:
<script type="text/javascript">
    function OnClientItemClicking(sender, args)
     {
        var item = args.get_item();
        if (item.get_text() == "Cut")
        {
            args.set_cancel(true);
        }
    }
</script>

Thanks,
Shinu.
Tags
Menu
Asked by
Tuhin Ghosh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or