/// <summary> /// 添加模板生成器 /// </summary> private void AddTemplateBuilder() { if (this.HasInnerHtml) { return; } InnerHtml.AppendHtml(_templateBuilder); }
/// <summary> /// Renders the HTML tag by using the specified render mode. /// </summary> /// <param name="renderMode">The render mode.</param> /// <returns>The rendered HTML tag.</returns> public string ToString(TagRenderMode renderMode) { this.TagRenderMode = renderMode; if (renderMode != TagRenderMode.EndTag) { foreach (var html in HtmlList) { InnerHtml.AppendHtml(html.ToString()); } } StringWriter writer = new StringWriter(); WriteTo(writer, HtmlEncoder.Default); return(writer.ToString()); }
public FileUploaderTagBuilder(string name, string controllerName, IEnumerable <string> allowedExtensions, int fileMaxSize, int numberOfFilesToUpload, bool multiple, string onSuccessCallback, string onDeleteCallback) : base("div") { var id = TagBuilder.CreateSanitizedId(name, "_"); string divName = string.Format("{0}_attachement_div", id); string allowedExtensionsString = string.Format("[{0}]", string.Join(',', allowedExtensions.Select(x => $"'{x}'"))); InnerHtml.AppendHtml(string.Format("<div id='{0}' class='uploader'><div class='file_uploader'></div><div class='file_uploader_message'></div></div>", divName)); InnerHtml.AppendHtml(string.Format("<script>$(function () {{initUploader('{0}', '{1}', '{2}', {3}, {4}, '{5}', '{6}', '{7}', {8});}});</script>", divName, id, controllerName, allowedExtensionsString, fileMaxSize.ToString(), onSuccessCallback, onDeleteCallback, multiple, numberOfFilesToUpload )); }