0

我在 asp.net web 表单项目的母版页上使用 PoupControl 作为 Base Popups。我的问题是;在显示弹出窗口一次后,弹出窗口出现在每个页面渲染中。当单击弹出窗口上的关闭或确定按钮时,弹出窗口是隐藏的。它不应该出现在每个页面呈现之后。我尝试使用 ShowOnPageLoad="false" 但它不起作用。

像这样掌握 .aspx 页面;

 <dx:ASPxPopupControl ID="BasePopupControl" runat="server" Modal="true" HeaderText="" CloseAction="CloseButton" Theme="Moderno"
    PopupHorizontalAlign="WindowCenter" AllowDragging="True" HeaderImage-IconID="actions_cancel_32x32" PopupVerticalAlign="WindowCenter"
    Width="350" Height="150" ClientInstanceName="BasePopupControl" ShowOnPageLoad="false">
    <ContentCollection>
        <dx:PopupControlContentControl ID="PopupControlContentControl2" runat="server" HeaderStyle-HorizontalAlign="Left" HorizontalAlign="Center">
            <table width="100%">
                <tr align="center">
                    <td>
                        <dx:ASPxLabel runat="server" ID="lblMessage" ClientInstanceName="lblMessage" Theme="Moderno"></dx:ASPxLabel>
                    </td>
                </tr>
                <tr>
                    <td></td>
                </tr>
                <tr align="center">
                    <td>
                        <dx:ASPxButton ID="btnPopupOK" runat="server" Text="Tamam" Theme="Moderno">
                            <ClientSideEvents Click="function(s, e) { BasePopupControl.Hide(); e.processOnServer = false; }" />
                        </dx:ASPxButton>
                    </td>
                </tr>
            </table>
        </dx:PopupControlContentControl>
    </ContentCollection>
</dx:ASPxPopupControl>
<dx:ASPxGlobalEvents runat="server" ID="GlobalEvent" EnableViewState="false"></dx:ASPxGlobalEvents>

这些用于显示弹出窗口的代码;

ASPxGlobalEvents popupEvent = null;
ASPxPopupControl popupControl = null;

if (this.Master != null)
{
    popupEvent = (ASPxGlobalEvents)this.Master.FindControl("GlobalEvent");
    popupControl = (ASPxPopupControl)this.Master.FindControl("BasePopupControl");
}
else
{
    popupEvent = (ASPxGlobalEvents)this.Page.FindControl("GlobalEvent");
    popupControl = (ASPxPopupControl)this.Page.FindControl("BasePopupControl");
}

if (popupEvent != null)
{
    popupEvent.ClientSideEvents.ControlsInitialized = "function(s,e){lblMessage.SetText('" + Message + "'); BasePopupControl.Show();}";

    switch (Type)
    {
        case BasePopupType.Error:
            popupControl.HeaderImage.IconID = IconID.ActionsCancel32x32;
            break;

        case BasePopupType.Success:
            popupControl.HeaderImage.IconID = IconID.ActionsApply32x32;
            break;

        default:
        case BasePopupType.Info:
            popupControl.HeaderImage.IconID = IconID.SupportInfo32x32;
            break;


    }
4

3 回答 3

0

如果你的 UI 中有其他控件的回调事件,那么你需要在结束回调事件下隐藏弹出控件。

还隐藏BasePopupControl在按钮单击事件中btnPopupNo

PopupEvent.ClientSideEvents.ControlsInitialized = "function(s,e){BasePopupControl.Hide();}";
于 2016-03-22T11:40:14.177 回答
0
protected void ShowMessage(string Message, BasePopupType Type)
{
    try
    {
        ASPxGlobalEvents popupEvent = null;
        ASPxPopupControl popupControl = null;

        if (this.Master != null)
        {
            popupEvent = (ASPxGlobalEvents)this.Master.FindControl("GlobalEvent");
            popupControl = (ASPxPopupControl)this.Master.FindControl("BasePopupControl");
        }
        else
        {
            popupEvent = (ASPxGlobalEvents)this.Page.FindControl("GlobalEvent");
            popupControl = (ASPxPopupControl)this.Page.FindControl("BasePopupControl");
        }

        if (popupEvent != null)
        {
            popupEvent.ClientSideEvents.ControlsInitialized = "function(s,e){lblMessage.SetText('" + Message + "'); BasePopupControl.Show();}";

            switch (Type)
            {
                case BasePopupType.Error:
                    popupControl.HeaderImage.IconID = IconID.ActionsCancel32x32;
                    break;

                case BasePopupType.Success:
                    popupControl.HeaderImage.IconID = IconID.ActionsApply32x32;
                    break;

                default:
                case BasePopupType.Info:
                    popupControl.HeaderImage.IconID = IconID.SupportInfo32x32;
                    break;
            }

        }
        else
        {
            string script = "javascript:alert('" + Message + "');";
        }
    }
    catch (Exception)
    {
        string script = "javascript:alert('" + Message + "');";
    }
}`enter code here`
于 2016-03-21T12:44:39.320 回答
0

其中一种方法调用 ShowMessage 方法。

protected void btnPopupNo__Click(object sender, EventArgs e)
            {
                PopupEvent.ClientSideEvents.ControlsInitialized = "function(s,e){MessagePopupControl.Hide();}";

                List<object> reconcilationList = Session["ReconcilationList"] as List<object>;
                ReconcilationManager manager = new ReconcilationManager();
                StringBuilder errorMsg = new StringBuilder();
                RCN_RECONCILATION oReconcilation = new RCN_RECONCILATION();
                bool result = false;

                foreach (object[] reconcilation in reconcilationList)
                {
                    try
                    {
                        if (Convert.ToInt32(reconcilation[0]) == (int)ReconcilationStatus.OnayaGonder)
                        {
                            int reconcilationIDX = Convert.ToInt32(((object[])reconcilation)[1]);
                            oReconcilation = manager.GetReconcilationByIDX(reconcilationIDX);
                            result = manager.SendReconcilationForApprove(oReconcilation);
                        }
                    }
                    catch (OperationCanceledException ex)
                    {
                        errorMsg.Append(" \\n " + oReconcilation.ReconcilationNo + " Numaralı mütabakat gönderilemedi: " + ex.Message);
                    }
                    catch (DBConnectionException ex)
                    {
                        errorMsg.Append(" \\n " + oReconcilation.ReconcilationNo + " Numaralı mütabakat gönderilemedi: Hata Kodu: " + ex.ErrorCode + ", " + ex.ErrorMessage);
                    }
                    catch (DBValidationException ex)
                    {
                        errorMsg.Append(" \\n " + oReconcilation.ReconcilationNo + " Numaralı mütabakat gönderilemedi: Hata Kodu: " + ex.ErrorCode + ", " + ex.ErrorMessage);
                    }
                    catch (MailProviderException ex)
                    {
                        errorMsg.Append(" \\n " + oReconcilation.ReconcilationNo + " Numaralı mütabakat gönderilemedi: Hata Kodu: " + ex.ErrorCode + ", " + ex.ErrorMessage);
                    }
                    catch (Exception ex)
                    {
                        errorMsg.Append("\\n " + oReconcilation.ReconcilationNo + " Numaralı mütabakat gönderilemedi.");
                    }
                }


                if (errorMsg.Length > 0)
                {
                    ShowMessage(errorMsg.ToString(), BasePopupType.Error);
                }
                else if (result)
                {
                    ASPxGridView1.DataBind();
                    ShowMessage("İşlem tamamlandı.", BasePopupType.Success);
                }
            }
于 2016-03-21T15:12:54.217 回答