我在asp.net web表单项目的母版页上使用PoupControl for 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;
}
答案 0 :(得分: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`
答案 1 :(得分: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);
}
}
答案 2 :(得分:0)
如果您的UI中有其他控件的回调事件,则需要在结束回调事件下隐藏弹出控件。
同时隐藏按钮点击事件BasePopupControl
中的btnPopupNo
:
PopupEvent.ClientSideEvents.ControlsInitialized = "function(s,e){BasePopupControl.Hide();}";