add delete confirmation to AJAX-enabled Context Menu

3 posts, 1 answers
  1. lina fetisova
    lina fetisova avatar
    110 posts
    Member since:
    Apr 2010

    Posted 06 Aug 2010 Link to this post

    Good day!
    Can I add delete confirmation when I select "Delete" in such a menu?
    http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandmenu/defaultcs.aspx?product=menu

    Is it possible to call to javascript function from such a C# code:
    protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
            {
                int radGridClickedRowIndex;

                radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]);

                switch (e.Item.Text)
                {
                    case "Edit":
                        RadGrid1.Items[radGridClickedRowIndex].Edit = true;
                        RadGrid1.Rebind();
                        break;
                    case "Add":
                        RadGrid1.MasterTableView.IsItemInserted = true;
                        RadGrid1.Rebind();
                        break;
                    case "Delete":
                        RadGrid1.MasterTableView.PerformDelete(RadGrid1.Items[radGridClickedRowIndex]);
                        break;
                }
            }

    ?
  2. Answer
    Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 06 Aug 2010 Link to this post

    Hello Lina,

    To accomplish that you need to handle the OnClientItemClicking event. Like so:

    function OnClientItemClicking(sender, args) {
                var item = args.get_item();
                if (item.get_text() == "Delete") {
                    args.set_cancel(!confirm("Are you sure you want to delete?"));
                }
            }


    I hope that helps.
  3. lina fetisova
    lina fetisova avatar
    110 posts
    Member since:
    Apr 2010

    Posted 08 Aug 2010 Link to this post

    thank you very much, Cori!
Back to Top