I needed to keep an Ajax modal dialog open until someone either clicked Cancel or clicked OK and had checked the "I accept the Terms and Condtions" dialog.
The solution turned out very straightforward:
In the OK button click handler, look to see if the checkbox is checked. Then find the ModalPopupExtender and call its Show() method.
This has the effect of keeping the Modal up (no flicker).
The painful bit is finding the modalPopupExtender in the control hierarchy.
Here is my code (C#)
protected void btnOK_Click(object sender, EventArgs e)
{
if
(chkAccept.Checked == false)
{
Button btnOK = (Button)sender;
Panel pnlAccept = (Panel)btnOK.Parent;
Panel pnlReportsDetail = (Panel)pnlAccept.Parent;
AjaxControlToolkit.
ModalPopupExtender mpe = (AjaxControlToolkit.ModalPopupExtender)pnlReportsDetail.FindControl ("ModalPopupExtender");
// The show method re-shows the modal dialog so it's in your face until you click Cancel or check the Accept checkbox
mpe.Show();
}
else
{
ProcessPayment();
}