protected override void CreateChildControls() { HeaderTemplateContainer headerTemplateContainer = null; BodyTemplateContainer bodyTemplateContainer = null; FooterTemplateContainer footerTemplateContainer = null; if (Header != null) { headerTemplateContainer = new HeaderTemplateContainer(); Header.InstantiateIn(headerTemplateContainer); Controls.Add(headerTemplateContainer); } if (Body != null) { bodyTemplateContainer = new BodyTemplateContainer(); Body.InstantiateIn(bodyTemplateContainer); Controls.Add(bodyTemplateContainer); } if (Footer != null) { footerTemplateContainer = new FooterTemplateContainer(); Footer.InstantiateIn(footerTemplateContainer); Controls.Add(footerTemplateContainer); } if (!string.IsNullOrEmpty(this.CancelButtonID)) { if (bodyTemplateContainer != null || footerTemplateContainer != null) { WebControl cancelButton = null; if (bodyTemplateContainer.FindControl(this.CancelButtonID) != null) { cancelButton = (bodyTemplateContainer.FindControl(this.CancelButtonID) as WebControl); } if (footerTemplateContainer.FindControl(this.CancelButtonID) != null) { cancelButton = (footerTemplateContainer.FindControl(this.CancelButtonID) as WebControl); } if (cancelButton != null) { cancelButton.Attributes.Add("data-dismiss", "modal"); } else { throw new Exception("The referenced object as CancelButtonID was not found."); } } } }