2016-03-21 106 views
0

我在asp.net web窗體項目的母版頁上使用PoupControl作爲基礎彈出窗口。我的問題是;在彈出一次後,彈出窗口會出現在每個頁面上。當點擊彈出窗口上的關閉或確定按鈕時,彈出窗口被隱藏。它不應該出現在每個頁面渲染之後。我嘗試使用ShowOnPageLoad =「false」,但它不能工作。ASPxPopupControl出現在每個頁面加載

Master .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
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` 
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); 
       } 
      } 
0

如果在UI中有其他控件的回調事件,則需要隱藏結束回調事件下的彈出控件。

而且隱藏按鈕單擊事件btnPopupNoBasePopupControl

PopupEvent.ClientSideEvents.ControlsInitialized = "function(s,e){BasePopupControl.Hide();}";