/// <summary> /// This is where you implment the simple aspects of rendering your control. The rest /// will be handled by calling RenderControlHelper's RenderControl() method. /// </summary> /// <param name="writer">The writer.</param> public void RenderBaseControl(HtmlTextWriter writer) { writer.AddAttribute("class", "fileupload-group"); writer.RenderBeginTag(HtmlTextWriterTag.Div); if (BinaryFileId != null) { _aFileName.HRef = string.Format("{0}GetFile.ashx?id={1}", ResolveUrl("~"), BinaryFileId); _aFileName.InnerText = new BinaryFileService().Queryable().Where(f => f.Id == BinaryFileId).Select(f => f.FileName).FirstOrDefault(); _aFileName.AddCssClass("file-exists"); _aRemove.Style[HtmlTextWriterStyle.Display] = "inline"; } else { _aFileName.HRef = string.Empty; _aFileName.InnerText = string.Empty; _aFileName.RemoveCssClass("file-exists"); _aRemove.Style[HtmlTextWriterStyle.Display] = "none"; } writer.AddAttribute("class", "fileupload-thumbnail"); writer.RenderBeginTag(HtmlTextWriterTag.Div); _hfBinaryFileId.RenderControl(writer); _hfBinaryFileTypeGuid.RenderControl(writer); _aFileName.RenderControl(writer); writer.RenderEndTag(); writer.AddAttribute("class", "fileupload-remove"); writer.RenderBeginTag(HtmlTextWriterTag.Div); _aRemove.RenderControl(writer); writer.RenderEndTag(); // render drop zone writer.AddAttribute(HtmlTextWriterAttribute.Class, "fileupload-dropzone"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write("drop / click to upload"); writer.RenderEndTag(); _fileUpload.Attributes["name"] = string.Format("{0}[]", this.ID); _fileUpload.RenderControl(writer); writer.RenderEndTag(); RegisterStartupScript(); writer.RenderEndTag(); }
/// <summary> /// This is where you implement the simple aspects of rendering your control. The rest /// will be handled by calling RenderControlHelper's RenderControl() method. /// </summary> /// <param name="writer">The writer.</param> public void RenderBaseControl(HtmlTextWriter writer) { writer.AddAttribute("class", "fileupload-group"); writer.AddAttribute("id", this.ClientID); if (ToolTip.IsNotNullOrWhiteSpace()) { writer.AddAttribute("title", ToolTip); } writer.RenderBeginTag(HtmlTextWriterTag.Div); if (BinaryFileId != null || !string.IsNullOrWhiteSpace(this.UploadedContentFilePath)) { if (IsBinaryFile) { _aFileName.HRef = string.Format("{0}GetFile.ashx?id={1}", ResolveUrl("~"), BinaryFileId); _aFileName.InnerText = new BinaryFileService(new RockContext()).Queryable().Where(f => f.Id == BinaryFileId).Select(f => f.FileName).FirstOrDefault(); } else { _aFileName.HRef = ResolveUrl(this.UploadedContentFilePath); _aFileName.InnerText = this.UploadedContentFilePath; } _aFileName.AddCssClass("file-exists"); _aRemove.Style[HtmlTextWriterStyle.Display] = "block"; } else { _aFileName.HRef = string.Empty; _aFileName.InnerText = string.Empty; _aFileName.RemoveCssClass("file-exists"); _aRemove.Style[HtmlTextWriterStyle.Display] = "none"; } if (this.Enabled) { if (this.DisplayMode == UploaderDisplayMode.DropZone) { writer.AddAttribute("class", "fileupload-thumbnail"); writer.RenderBeginTag(HtmlTextWriterTag.Div); _hfBinaryFileId.RenderControl(writer); _hfBinaryFileTypeGuid.RenderControl(writer); _aFileName.RenderControl(writer); writer.AddAttribute("class", "fileupload-remove"); if (!ShowDeleteButton) { writer.AddStyleAttribute(HtmlTextWriterStyle.Visibility, "hidden"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); _aRemove.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); } string uploadClass = this.DisplayMode == UploaderDisplayMode.DefaultButton ? "upload-progress-sm" : "upload-progress"; string spinnerSize = this.DisplayMode == UploaderDisplayMode.DefaultButton ? "fa-lg" : "fa-3x"; writer.Write($@" <div class='js-upload-progress {uploadClass}' style='display:none;'> <i class='fa fa-refresh {spinnerSize} fa-spin'></i> <div class='js-upload-progress-percent'></div> </div>"); if (this.DisplayMode == UploaderDisplayMode.Button) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "fileupload-button"); } else if (this.DisplayMode == UploaderDisplayMode.DefaultButton) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "fileuploaddefault-button"); } else { writer.AddAttribute(HtmlTextWriterAttribute.Class, "fileupload-dropzone"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(this.UploadButtonText); writer.RenderEndTag(); _fileUpload.Attributes["name"] = string.Format("{0}[]", this.ID); _fileUpload.RenderControl(writer); writer.RenderEndTag(); } RegisterStartupScript(); writer.RenderEndTag(); }
/// <summary> /// This is where you implment the simple aspects of rendering your control. The rest /// will be handled by calling RenderControlHelper's RenderControl() method. /// </summary> /// <param name="writer">The writer.</param> public void RenderBaseControl(HtmlTextWriter writer) { writer.AddAttribute("class", "fileupload-group"); writer.AddAttribute("id", this.ClientID); writer.RenderBeginTag(HtmlTextWriterTag.Div); if (BinaryFileId != null || !string.IsNullOrWhiteSpace(this.UploadedContentFilePath)) { if (IsBinaryFile) { _aFileName.HRef = string.Format("{0}GetFile.ashx?id={1}", ResolveUrl("~"), BinaryFileId); _aFileName.InnerText = new BinaryFileService(new RockContext()).Queryable().Where(f => f.Id == BinaryFileId).Select(f => f.FileName).FirstOrDefault(); } else { _aFileName.HRef = string.Format("{0}GetFile.ashx?isBinaryFile=F&rootFolder={1}&fileName={2}", ResolveUrl("~"), Rock.Security.Encryption.EncryptString(this.RootFolder), BinaryFileId); _aFileName.InnerText = this.UploadedContentFilePath; } _aFileName.AddCssClass("file-exists"); _aRemove.Style[HtmlTextWriterStyle.Display] = "block"; } else { _aFileName.HRef = string.Empty; _aFileName.InnerText = string.Empty; _aFileName.RemoveCssClass("file-exists"); _aRemove.Style[HtmlTextWriterStyle.Display] = "none"; } if (this.Enabled) { if (this.DisplayMode == UploaderDisplayMode.DropZone) { writer.AddAttribute("class", "fileupload-thumbnail"); writer.RenderBeginTag(HtmlTextWriterTag.Div); _hfBinaryFileId.RenderControl(writer); _hfBinaryFileTypeGuid.RenderControl(writer); _aFileName.RenderControl(writer); writer.AddAttribute("class", "fileupload-remove"); if (!ShowDeleteButton) { writer.AddStyleAttribute(HtmlTextWriterStyle.Visibility, "hidden"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); _aRemove.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); } writer.Write(@" <div class='js-upload-progress upload-progress' style='display:none;'> <i class='fa fa-refresh fa-3x fa-spin'></i> </div>"); if (this.DisplayMode == UploaderDisplayMode.Button) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "fileupload-button"); } else { writer.AddAttribute(HtmlTextWriterAttribute.Class, "fileupload-dropzone"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Span); if (this.DisplayMode == UploaderDisplayMode.Button) { writer.Write("Upload File"); } else { writer.Write("Upload"); } writer.RenderEndTag(); _fileUpload.Attributes["name"] = string.Format("{0}[]", this.ID); _fileUpload.RenderControl(writer); writer.RenderEndTag(); } RegisterStartupScript(); writer.RenderEndTag(); }