public void RegisterDisplayModalPopup()
{
if(!String.IsNullOrEmpty(DisplayModalPopupID)) {
// Find the specified ModalPopupExtender and validate it
var mpe = FindControlHelper(DisplayModalPopupID) as ModalPopupExtender;
if(mpe == null)
throw new ArgumentException("Unable to find specified ModalPopupExtender.");
if(mpe.TargetControlID != TargetControlID)
throw new ArgumentException("ConfirmButton and the ModalPopupExtender specified by its DisplayModalPopupID must specify the same TargetControlID.");
if(String.IsNullOrEmpty(mpe.OkControlID) && String.IsNullOrEmpty(mpe.CancelControlID))
throw new ArgumentException("Specified ModalPopupExtender must set at least OkControlID and/or CancelControlID.");
if(!String.IsNullOrEmpty(mpe.OnOkScript) || !String.IsNullOrEmpty(mpe.OnCancelScript))
throw new ArgumentException("Specified ModalPopupExtender may not set OnOkScript or OnCancelScript.");
// Re-point the ModalPopupExtender to an invisible placeholder button
// The following might better be done in OnPreRender, but because of non-deterministic
// ordering with respect to when the ModalPopupExtender will register itself with the
// ScriptManager (also in OnPreRender), we need to re-point it a stage earlier.
var placeholder = new Button();
placeholder.ID = ID + "_CBE_MPE_Placeholder";
placeholder.Style[HtmlTextWriterStyle.Display] = "none";
Controls.Add(placeholder);
mpe.TargetControlID = placeholder.ID;
// The behavior will need to be able to initiate a postback
PostBackScript = Page.ClientScript.GetPostBackEventReference(TargetControl, String.Empty);
}
}