public static MvcHtmlString PrimaryModelName <TModel>(this HtmlHelper <TModel> html) { object o = html.ViewData.Model; ValidationUtility.AssertNotNull(o, new ArgumentNullException("ViewData.Model")); return(new MvcHtmlString(StringUtility.LowercaseFirst(o.GetType().Name))); }
public static MvcHtmlString NgNumberInput <TModel, TValue>(this HtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, decimal min = 0.01m, string placeholder = "") { object o = html.ViewData.Model; ValidationUtility.AssertNotNull(o, new ArgumentNullException("ViewData.Model")); string formName = StringUtility.LowercaseFirst(o.GetType().Name); string name = StringUtility.LowercaseFirst(html.NameFor(expression).ToString()); string model = string.Format("{0}.{1}", formName, name); TagBuilder tb = new TagBuilder("input"); tb.AddCssClass("form-control"); tb.Attributes.Add("type", "number"); tb.Attributes.Add("name", name); tb.Attributes.Add("ng-model", model); tb.Attributes.Add("ng-blur", string.Format("blurred.{0} = true", name)); tb.Attributes.Add("min", min.ToString()); tb.Attributes.Add("placeholder", placeholder); return(new MvcHtmlString(tb.ToString())); }