Contenxt Menu Confirm

2 posts, 1 answers
  1. Stephen
    Stephen avatar
    38 posts
    Member since:
    Mar 2008

    Posted 22 Jan 2009 Link to this post

    I got what I wanted working very quickly because the control works well but got stuck on the last feature. I had a tree that the user could click on but they wanted edit|delete|view option and I added that easily. But I wanted a confirmation on the delete. I tried to catch the OnClientContextMenuItemClicked but then there is no functionality on the tree at all and it looks like I have to handle it all myself. The only other option is going through the postback to raise a new dialog to ask for confirmation.

    Anyone have a quicker way to do this? All I want to do is confirm the delete option.


    Updated: ok, I must have done something wrong because I can call the clientside function and it still acts properly. Is there a way I can change what happens after I return from the client side function. What I'd like it to be able to affect or cancel the server side post under certain conditions.

    Updated: ok, never mind, this was as simple as I had hoped it would be

    function TestIt(sender, eventArgs) {
      var item = eventArgs.get_menuItem();
      if (item.get_text() == "Delete") {
        if (!confirm("Do you really want to delete that item")) {

  2. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Jan 2009 Link to this post

    Hi Stephen,

    Try the following client side  function attached with OnClientContextMenuItemClicking instead of OnClientContextMenuItemClicked, in order to cancel the server side ContextMenu click event.

    <script type="text/javascript"
    function TestIt(sender, eventArgs) 
        var item = eventArgs.get_menuItem(); 
        if (item.get_text() == "Delete"
            if (!confirm("Do you really want to delete that item")) 

    <telerik:RadTreeView ID="RadTreeView1" Runat="server" OnClientContextMenuItemClicking="TestIt" oncontextmenuitemclick="RadTreeView1_ContextMenuItemClick"

Back to Top