protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if(!DesignMode) {
// Check if EnableSanitization is enabled and sanitizer provider is not configured.
if(EnableSanitization && Sanitizer == null)
throw new Exception("The Sanitizer is not configured in the web.config file. Either install the AjaxControlToolkit.HtmlEditor.Sanitizer NuGet package or set the EnableSanitization property to False (insecure).");
EnsureButtons();
var popupdiv = new HtmlGenericControl("div");
popupdiv.Attributes.Add("Id", this.ClientID + "_popupDiv");
popupdiv.Attributes.Add("style", "opacity: 0;");
popupdiv.Attributes.Add("class", "ajax__html_editor_extender_popupDiv");
ajaxFileUpload = new AjaxFileUpload();
ajaxFileUpload.ID = this.ID + "_ajaxFileUpload";
ajaxFileUpload.MaximumNumberOfFiles = 10;
ajaxFileUpload.AllowedFileTypes = "jpg,jpeg,gif,png";
ajaxFileUpload.Enabled = true;
ajaxFileUpload.OnClientUploadComplete = "ajaxClientUploadComplete";
if(ImageUploadComplete != null) {
ajaxFileUpload.UploadComplete += ImageUploadComplete;
}
if(HasImageButton()) {
var button = (InsertImage)ToolbarButtons.FirstOrDefault(b => b.CommandName == InsertImageCommandName);
if(!String.IsNullOrWhiteSpace(button.AjaxFileUploadHandlerPath))
ajaxFileUpload.UploadHandlerPath = button.AjaxFileUploadHandlerPath;
}
popupdiv.Controls.Add(ajaxFileUpload);
var btnCancel = new HtmlGenericControl("div");
btnCancel.Attributes.Add("Id", this.ClientID + "_btnCancel");
btnCancel.Attributes.Add("style", "float: right; position:relative; padding-left: 20px; top:10px; width: 55px; border-color:black;border-style: solid; border-width: 1px;cursor:pointer;");
btnCancel.Attributes.Add("float", "right");
btnCancel.Attributes.Add("unselectable", "on");
btnCancel.InnerText = "Cancel";
popupdiv.Controls.Add(btnCancel);
this.Controls.Add(popupdiv);
}
}