我的页面中有一个Ajax ModalPopupExtender。当前使用TargetControlId的按钮点击我显示弹出窗口。我需要的是当我点击按钮想要从DB检查一些条件时。如果条件满足我要显示弹出。其他明智的不需要弹出。我怎么能这样做?
<ajaxToolkit:ModalPopupExtender CancelControlID="btnCancel" BackgroundCssClass="modalBackground" runat="server" ID="PopupExtender" TargetControlID="btn" PopupControlID="Panel1"></ajaxToolkit:ModalPopupExtender>
答案 0 :(得分:2)
试试这个
protected void Button1_Click(object sender, EventArgs e)
{
PopupExtender.Show();
}
答案 1 :(得分:2)
protected void ButtonSave_Click(object sender, EventArgs e)
{
if (MyCondition == true)
{
modalPopUpConfirmation.Show();
}
else
{
Label1.Text = "The condition was false, so no modal popup!";
}
}
答案 2 :(得分:1)
动态调用它。
<!-- Hidden Field -->
<asp:HiddenField ID="hidForModel" runat="server" />
<ajaxToolkit:ModalPopupExtender CancelControlID="btnCancel" BackgroundCssClass="modalBackground" runat="server" ID="PopupExtender" TargetControlID="hidForModel" PopupControlID="Panel1"></ajaxToolkit:ModalPopupExtender>
<asp:Button ID="btnShowPopup" runat="server" Text="Save Data"
OnClick="btnShowPopup_Click" />
代码背后
protected void btnShowPopup_Click(object sender, EventArgs e)
{
if(Yourcondition)
{
PopupExtender.Show();
}
}