RadContextMenu not firing Ajax Modal Popup Extender

2 posts, 0 answers
  1. Paul
    Paul avatar
    6 posts
    Member since:
    Sep 2018

    Posted 19 Feb Link to this post

    Hi,

    I have a split button and RadContextMenu, however for the life of me cannot get the MPE to fire from the Context items and its driving me up the wall. Can anyone please help point me in the right direction.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShowModal.aspx.cs"
        Inherits="Default" %>
     
    <%@ Register Namespace="AjaxControlToolkit" TagPrefix="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            </telerik:RadScriptManager>
     
            <telerik:RadButton EnableSplitButton="true" ID="btnPOSplitBtn" runat="server" Text="Search"
                OnClientClicked="OnClientClicked">
            </telerik:RadButton>
            <telerik:RadContextMenu ID="POActionsMenu" runat="server" OnItemClick="POActionsMenu_ItemClick">
                <Items>
     
                    <telerik:RadMenuItem Text="Export CSV" Value="3">
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Change Status to Printed" Value="4">
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Delete Purchase Order" Value="5">
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadContextMenu>
     
            <%-- Alert Box --%>
            <asp:LinkButton ID="lnkConfirm" runat="server"></asp:LinkButton>
            <AjaxControlToolkit:ModalPopupExtender ID="mpeConfirm" runat="server" DropShadow="false" PopupControlID="pnlConfirm" TargetControlID="lnkConfirm" BackgroundCssClass="modalBackground" BehaviorID="Confirmations" CancelControlID="btnCloseConfirm">
            </AjaxControlToolkit:ModalPopupExtender>
            <asp:Panel ID="pnlConfirm" runat="server" CssClass="modalPopup" Style="display: none; width: 80%; max-height: 80%; overflow-y: auto;">
     
                <h2>Are you sure?</h2>
                <p>
     
                    <asp:Label ID="lblConfirmAlert" runat="server"></asp:Label>
                </p>
     
                <telerik:RadButton ID="btnConfirmClose" runat="server" Text="No - Close" UseSubmitBehavior="false" />
            </asp:Panel>
     
            <telerik:RadScriptBlock runat="server">
                <script type="text/javascript">
     
                    function OnClientClicked(sender, args) {
                        if (args.IsSplitButtonClick()) {
                            var currentLocation = $telerik.getLocation(sender.get_element());
                            var contextMenu = $find("<%=POActionsMenu.ClientID%>");
                            contextMenu.showAt(currentLocation.x + 75, currentLocation.y + 32);
     
                            sender.set_autoPostBack(false);
                        }
                        else {
                            sender.set_autoPostBack(true);
     
                        }
                    }
                </script>
            </telerik:RadScriptBlock>
        </form>
    </body>
    </html>

     

    and my code behind.

    using System;
    using Telerik.Web.UI;
     
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
     
        protected void POActionsMenu_ItemClick(object sender, RadMenuEventArgs e)
        {
            RadContextMenu btn = (RadContextMenu)(sender);
     
            string value = btn.SelectedValue;
     
            switch (value)
            {
                //View PO
                case "1":
     
                    break;
     
                //Send me a copy
                case "2":
     
                    break;
                //Export CSV
                case "3":
     
                    break;
     
                //Change status to printed
                case "4":
     
                    //   btnConfirmYes.CommandArgument = "Change to Printed";
                    mpeConfirm.Show();
     
                    //changeStatusToP();
     
                    break;
     
                //Delete po
                case "5":
     
                    //    btnConfirmYes.CommandArgument = "Delete PO";
                    mpeConfirm.Show();
     
                    // deletePO();
                    break;
            }
        }
    }

     

    Thanks in advance, its driving me crazy as it hits the mpeConfirm.show() event but never shows. (CSS not included)

  2. Paul
    Paul avatar
    6 posts
    Member since:
    Sep 2018

    Posted 20 Feb Link to this post

    Update:

    Weirdly, recreating the modal popup with different control names fixed the issue and all working.

Back to Top