public HtmlFieldPrefixScope(TemplateInfo templateInfo, string htmlFieldPrefix) { this.templateInfo = templateInfo; previousHtmlFieldPrefix = templateInfo.HtmlFieldPrefix; templateInfo.HtmlFieldPrefix = htmlFieldPrefix; }
public HtmlFieldPrefixScope(TemplateInfo templateInfo, string htmlFieldPrefix) { TemplateInfo = templateInfo; PreviousHtmlFieldPrefix = TemplateInfo.HtmlFieldPrefix; TemplateInfo.HtmlFieldPrefix = htmlFieldPrefix; }
public static bool HasError(this ModelStateDictionary modelState, TemplateInfo templateInfo, string propertyName) { var htmlFieldPrefix = templateInfo.HtmlFieldPrefix; if (!string.IsNullOrEmpty(htmlFieldPrefix)) { propertyName = string.Format("{0}.{1}", htmlFieldPrefix, propertyName); } return modelState.Any(m => m.Key == propertyName) && modelState[propertyName].Errors != null && modelState[propertyName].Errors.Count > 0; }
public static ModelMetadata BuildDropdownListenerAttributes(this ModelMetadata metadata, TemplateInfo templateInfo, ref IDictionary<string, object> attributes) { if (metadata.AdditionalValues.ContainsKey("dropdownlistener")) { var parentName = metadata.AdditionalValues["dropdownlistener-parent"].ToString(); var id = templateInfo.GetFullHtmlFieldId(parentName); attributes.Add("data-dropdownlistener", true); attributes.Add("data-dropdownlistener-parent", parentName); attributes.Add("data-dropdownlistener-callback", metadata.AdditionalValues["dropdownlistener-callback"]); } return metadata; }
private static bool ShouldShow(ModelMetadata metadata, TemplateInfo templateInfo) { if (metadata.ShowForEdit && metadata.ModelType != typeof(System.Data.EntityState) // do not show internal Entity State && (metadata.DataTypeName == "Upload" || metadata.TemplateHint == "Upload" || !metadata.IsComplexType)) { return !templateInfo.Visited(metadata); } else { return false; } }
/// <summary> /// Determines whether [is property visible] [the specified metadata]. /// </summary> /// <param name="metadata">The metadata.</param> /// <param name="template">The template.</param> /// <returns><c>true</c> if [is property visible] [the specified metadata]; otherwise, <c>false</c>.</returns> public static bool IsPropertyVisible(this ModelMetadata metadata, TemplateInfo template) { return !metadata.HideSurroundingHtml && metadata.ShowForEdit && !template.Visited(metadata); }
public CollectionItemScope(TemplateInfo templateInfo, object index) { this.templateInfo = templateInfo; oldPrefix = templateInfo.HtmlFieldPrefix; templateInfo.HtmlFieldPrefix = string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", oldPrefix, index); }
/// <summary> /// Initializes a new instance of the <see cref="PrefixScope"/> class. /// </summary> /// <param name="templateInfo">The template info.</param> /// <param name="prefix">The HTML field prefix.</param> public PrefixScope(TemplateInfo templateInfo, string prefix) { if (templateInfo == null) { throw new ArgumentNullException("templateInfo"); } if (string.IsNullOrEmpty(prefix)) { throw new ArgumentNullException("prefix"); } _templateInfo = templateInfo; _previousPrefix = templateInfo.HtmlFieldPrefix; templateInfo.HtmlFieldPrefix = prefix; }