Skip to main content
 首页 » 编程设计

c#之Ajax ModalPopUp Window 根据特定条件

2024年02月01日33kenshinobiy

我的页面中有一个 Ajax ModalPopupExtender。在当前使用 TargetControlId 的按钮上单击我正在显示弹出窗口。我的需要是当我单击按钮时要检查数据库中的一些条件。如果条件满足我想显示弹出窗口。否则不需要弹出窗口。我该怎么做?

 <ajaxToolkit:ModalPopupExtender CancelControlID="btnCancel" BackgroundCssClass="modalBackground" runat="server" ID="PopupExtender"  TargetControlID="btn"  PopupControlID="Panel1"></ajaxToolkit:ModalPopupExtender> 

请您参考如下方法:

protected void ButtonSave_Click(object sender, EventArgs e) 
    { 
     if (MyCondition == true) 
        {            
           modalPopUpConfirmation.Show(); 
        } 
     else 
        {             
            Label1.Text = "The condition was false, so no modal popup!"; 
        } 
    }