/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Tag = HtmlTag.Div; foreach (var option in Options) { var label = new HtmlElement(HtmlTag.Label); Append(label); label.AddClass("checkbox-inline"); var input = new HtmlElement(HtmlTag.Input); label.Append(input); input.Attribute(HtmlAttribute.Type, "checkbox"); input.Attribute(HtmlAttribute.Name, Name); input.Attribute(HtmlAttribute.Value, option.Value); if (Values.Contains(option.Value)) { input.Attribute(HtmlAttribute.Checked, "checked"); } if (PropertyContent.Disabled || PropertyContent.ReadOnly) { input.Attribute(HtmlAttribute.Disabled, "disabled"); } HtmlData.SetContext(input); label.Append(new HtmlRaw(option.Text.HtmlEncode())); } }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Tag = HtmlTag.Div; foreach (var option in Source) { var label = new HtmlElement(HtmlTag.Label); Append(label); label.AddClass("radio-inline"); var input = new HtmlElement(HtmlTag.Input); label.Append(input); input.Attribute(HtmlAttribute.Type, "radio"); input.Attribute(HtmlAttribute.Name, Name); input.Attribute(HtmlAttribute.Value, option.Key.ToString().ToLower()); if (Value.HasValue && option.Key == Value.Value) { input.Attribute(HtmlAttribute.Checked, "checked"); } if (PropertyContent.Disabled || PropertyContent.ReadOnly) { input.Attribute(HtmlAttribute.Disabled, "disabled"); } HtmlData.SetContext(input); label.Append(new HtmlRaw(option.Value.HtmlEncode())); } }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Attribute(HtmlAttribute.Type, "hidden"); Attribute(HtmlAttribute.Name, Name); Attribute(HtmlAttribute.Value, Value); SetAttributeDisabledReadOnlyPlaceHolder(this, PropertyContent.Disabled); HtmlData.SetContext(this); }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Attribute(HtmlAttribute.Type, "number"); Attribute(HtmlAttribute.Name, Name); Attribute(HtmlAttribute.Value, Value == null ? string.Empty : Value.ToString()); SetAttributeDisabledReadOnlyPlaceHolder(this, PropertyContent.Disabled); AddClass("form-control"); HtmlData.SetContext(this); }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Tag = HtmlTag.Textarea; Attribute(HtmlAttribute.Name, Name); Attribute(HtmlAttribute.Rows, "5"); SetAttributeDisabledReadOnlyPlaceHolder(this, PropertyContent.Disabled); Text(Value); AddClass("form-control"); HtmlData.SetContext(this); }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Tag = HtmlTag.Div; AddClass("mulit-file-group"); if (!PropertyContent.Disabled && !PropertyContent.ReadOnly) { SetFileInput(); } foreach (var item in Value) { var group = new HtmlElement(HtmlTag.Div); group.AppendTo(this); group.AddClass("control-line"); var control = new HtmlElement(HtmlTag.Div); control.AppendTo(group); control.AddClass("form-control"); if (PropertyContent.ReadOnly) { control.Attribute(HtmlAttribute.ReadOnly, "readonly"); } if (PropertyContent.Disabled) { control.Attribute(HtmlAttribute.ReadOnly, "disabled"); } var icon = Util.ContentTypeMapping.Instance.ToIcon(item.ContentType, item.FileName); icon.CreateElement().AppendTo(control); var a = new HtmlElement(HtmlTag.A); a.Text(item.FileName); a.AddClass("icon-fa-text"); a.Attribute(HtmlAttribute.Href, item.Location); a.Attribute(HtmlAttribute.Target, "_none"); HtmlData.SetContext(a); a.AppendTo(control); var delInput = new HtmlElement(HtmlTag.Input); delInput.AppendTo(group); delInput.Attribute(HtmlAttribute.Type, "hidden"); delInput.Attribute(HtmlAttribute.Name, string.Format("{0}_DeleteMark", Name)); delInput.AddClass("del-file-input"); delInput.Attribute(HtmlAttribute.Value, "0"); if (FileOption.SupportDelete && (!PropertyContent.Disabled && !PropertyContent.ReadOnly)) { group.AddClass("input-group"); var span = new HtmlElement(HtmlTag.Span); span.AppendTo(group); span.AddClass("input-group-addon del-files"); span.Append(FontAwesome.Times.CreateElement()); } } SetFormValidator(); }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Attribute(HtmlAttribute.Type, "text"); Attribute(HtmlAttribute.Name, Name); Attribute(HtmlAttribute.Value, Value); if (InputMaxLength != null) { Attribute(HtmlAttribute.MaxLength, InputMaxLength.Length.ToString()); } SetAttributeDisabledReadOnlyPlaceHolder(this, PropertyContent.Disabled); AddClass("form-control"); HtmlData.SetContext(this); }
private void SetFileInput() { var group = new HtmlElement(HtmlTag.Div); group.AppendTo(this); group.AddClass("input-group control-line"); var span = new HtmlElement(HtmlTag.Span); span.AppendTo(group); span.AddClass("input-group-addon"); span.Append(new HtmlElement(HtmlTag.I).AddClass("fa fa-files-o")); var templateInput = new HtmlElement(HtmlTag.Input); templateInput.AppendTo(group); templateInput.Attribute(HtmlAttribute.Type, "file"); templateInput.Attribute(HtmlAttribute.Name, Name); HtmlData.SetContext(templateInput); templateInput.Data("temporary", "temporary"); templateInput.Data("temporary-for", Name); if (FileOption.Accept != Annotations.ContentType.None) { var list = new List <string>(); foreach (var item in FileOption.Accept.ToArray()) { var contentType = item.ToString().ToLower().Replace('_', '-'); if (FileOption.Extensions.Length == 0) { list.Add(string.Format("{0}/*", contentType)); } else { foreach (var extension in FileOption.Extensions) { list.Add(string.Format("{0}/{1}", contentType, extension.ToLower())); } } } templateInput.Attribute(HtmlAttribute.Accept, string.Join(",", list)); } templateInput.AddClass("template-mulit-file-input"); var virtualInput = new HtmlElement(HtmlTag.Div); virtualInput.AddClass("form-control virtual-mulit-file-input"); virtualInput.Text(string.IsNullOrEmpty(PropertyContent.Description) ? "选择多个文件" : PropertyContent.Description); virtualInput.AppendTo(group); SetAttributeDisabledReadOnly(virtualInput, PropertyContent.Disabled); }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Tag = HtmlTag.Select; Attribute(HtmlAttribute.Name, Name); Attribute(HtmlAttribute.Multiple, "multiple"); AddClass("form-control"); foreach (var option in Options) { var item = new HtmlElement(HtmlTag.Option); Append(item); item.Attribute(HtmlAttribute.Value, option.Value); if (Values.Contains(option.Value)) { item.Attribute(HtmlAttribute.Selected, "selected"); } item.Text(option.Text); } SetAttributeDisabledReadOnlyPlaceHolder(this, PropertyContent.ReadOnly || PropertyContent.Disabled); HtmlData.SetContext(this); }
/// <summary> /// 设置查看模式 /// </summary> public override void SetViewMode() { Tag = HtmlTag.Ul; AddClass("control-value"); foreach (var item in Value) { var li = new HtmlElement(HtmlTag.Li); li.AppendTo(this); var icon = Util.ContentTypeMapping.Instance.ToIcon(item.ContentType, item.FileName); li.Append(icon.CreateElement()); var a = new HtmlElement(HtmlTag.A); a.Text(item.FileName); a.AddClass("icon-fa-text"); a.Attribute(HtmlAttribute.Href, item.Location); a.Attribute(HtmlAttribute.Target, "_none"); HtmlData.SetContext(a); a.AppendTo(li); } }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Tag = HtmlTag.Div; AddClass("input-group"); var span = new HtmlElement(HtmlTag.Span); Append(span); span.AddClass("input-group-addon"); span.Append(FontAwesome.Calendar_O.CreateElement()); var input = new HtmlElement(HtmlTag.Input); Append(input); input.Attribute(HtmlAttribute.Type, "datetime-local"); input.Attribute(HtmlAttribute.Name, Name); input.Attribute(HtmlAttribute.Value, GetValue().Replace(" ", "T")); SetAttributeDisabledReadOnlyPlaceHolder(input, PropertyContent.ReadOnly || PropertyContent.Disabled); input.AddClass("form-control"); HtmlData.SetContext(input); }
/// <summary> /// 设置查看模式 /// </summary> public override void SetViewMode() { Tag = HtmlTag.Div; AddClass("control-value"); if (Value == null) { return; } var icon = Util.ContentTypeMapping.Instance.ToIcon(Value.ContentType, Value.FileName); Append(icon.CreateElement()); var a = new HtmlElement(HtmlTag.A); a.Text(Value.FileName); a.AddClass("icon-fa-text"); a.Attribute(HtmlAttribute.Href, Value.Location); a.Attribute(HtmlAttribute.Target, "_none"); HtmlData.SetContext(a); a.AppendTo(this); }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Tag = HtmlTag.Div; AddClass("input-group"); var span = new HtmlElement(HtmlTag.Span); Append(span); span.AddClass("input-group-addon"); span.Append(FontAwesome.Eye_Slash.CreateElement()); var input = new HtmlElement(HtmlTag.Input); Append(input); input.Attribute(HtmlAttribute.Type, "password"); input.Attribute(HtmlAttribute.Name, Name); input.Attribute(HtmlAttribute.Value, Value); SetAttributeDisabledReadOnlyPlaceHolder(input, PropertyContent.Disabled); input.AddClass("form-control"); HtmlData.SetContext(input); }
/// <summary> /// 设置输入模式 /// </summary> public override void SetInputMode() { Tag = HtmlTag.Div; AddClass("input-group"); var span = new HtmlElement(HtmlTag.Span); Append(span); span.AddClass("input-group-addon"); if (Value != null) { var icon = Util.ContentTypeMapping.Instance.ToIcon(Value.ContentType, Value.FileName); span.Append(icon.CreateElement()); var a = new HtmlElement(HtmlTag.A).Text(Value.FileName).AddClass("icon-fa-text").Attribute(HtmlAttribute.Href, Value.Location).Attribute(HtmlAttribute.Target, "_none"); HtmlData.SetContext(a); a.AppendTo(span); } else { span.Append(new HtmlElement(HtmlTag.I).AddClass("fa fa-file")); } var input = new HtmlElement(HtmlTag.Input); Append(input); if (!PropertyContent.ReadOnly && !PropertyContent.Disabled) { input.Attribute(HtmlAttribute.Type, "file"); } input.Attribute(HtmlAttribute.Name, Name); if (FileOption.Accept != Annotations.ContentType.None) { var list = new List <string>(); foreach (var item in FileOption.Accept.ToArray()) { var contentType = item.ToString().ToLower().Replace('_', '-'); if (FileOption.Extensions.Length == 0) { list.Add(string.Format("{0}/*", contentType)); } else { foreach (var extension in FileOption.Extensions) { list.Add(string.Format("{0}/{1}", contentType, extension.ToLower())); } } } input.Attribute(HtmlAttribute.Accept, string.Join(",", list)); } input.AddClass("single-file-input"); HtmlData.SetContext(input); var virtualInput = new HtmlElement(HtmlTag.Div); virtualInput.AddClass("form-control virtual-file-input"); virtualInput.Text(string.IsNullOrEmpty(PropertyContent.Description) ? "选择文件" : PropertyContent.Description); virtualInput.AppendTo(this); SetAttributeDisabledReadOnly(virtualInput, PropertyContent.Disabled); if (Value != null && !PropertyContent.ReadOnly && !PropertyContent.Disabled) { var delInput = new HtmlElement(HtmlTag.Input); Append(delInput); delInput.Attribute(HtmlAttribute.Type, "hidden"); delInput.Attribute(HtmlAttribute.Name, string.Format("{0}_DeleteMark", Name)); delInput.AddClass("del-file-input"); delInput.Attribute(HtmlAttribute.Value, "0"); if (FileOption.SupportDelete) { span = new HtmlElement(HtmlTag.Span); Append(span); span.AddClass("input-group-addon del-file"); span.Append(FontAwesome.Times.CreateElement()); } } SetFormValidator(); }