public static IHtmlString CheckBoxForFlagEnum <T>(this HtmlHelper <T> html, Enum item) { TemplateInfo templateInfo = html.ViewData.TemplateInfo; string id = templateInfo.GetFullHtmlFieldId(item.ToString()); string name = templateInfo.GetFullHtmlFieldId(string.Empty); var checkbox = new TagBuilder("input"); checkbox.Attributes["id"] = id; checkbox.Attributes["name"] = name; checkbox.Attributes["type"] = "checkbox"; checkbox.Attributes["value"] = item.ToString(); var model = html.ViewData.Model as Enum; if (model != null && model.HasFlag(item)) { checkbox.Attributes["checked"] = "checked"; } return(MvcHtmlString.Create(checkbox.ToString())); }
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); }
public static string GetFullHtmlFieldId <TModel, TProperty>(this TemplateInfo templateInfo, Expression <Func <TModel, TProperty> > expression) { return(templateInfo.GetFullHtmlFieldId(ExpressionHelper.GetExpressionText(expression))); }
public static string GetFullArrayHtmlFieldId(this TemplateInfo templateInfo, int index, string propertyName) { return(templateInfo.GetFullHtmlFieldId("") + "[" + index + "]" + "_" + propertyName); }
private string GetId <TPoperty>(Expression <Func <TModel, TPoperty> > expression) { return(_info.GetFullHtmlFieldId(ExpressionHelper.GetExpressionText(expression))); }