public static HtmlTag Input <TModel>(this IHtmlHelper <TModel> helper, Expression <Func <TModel, object> > expression) { var options = helper.ViewContext.HttpContext.RequestServices.GetService <HtmlConventionOptions>(); var tag = new TagGenerator(options.Conventions.Select(x => (HtmlConvention)helper.ViewContext.HttpContext.RequestServices.GetService(x)).ToList()); return(tag.GenerateInputFor(helper.ViewContext, expression)); }
public void ShouldBeAbleToGenerateTagForLooselyTypedProperty() { var setting = new Settings(); var accessor = ReflectionUtil.GetAccessor(setting.GetType().GetProperty("Name")); var tagGenerator = new TagGenerator(HtmlConventionFactory.HtmlConventions); var html = tagGenerator.GenerateInputFor(MvcMockHelpers.MockViewContext(), accessor); Assert.AreEqual("<input type=\"text\" id=\"Name\" name=\"Name\" />", html.ToString()); }
public void ShouldBeAbleToGenerateTagForLooselyTypedProperty() { var setting = new Settings(); var accessor = ReflectionUtil.GetAccessor(setting.GetType().GetProperty("Name")); var tagGenerator = new TagGenerator(HtmlConventionFactory.HtmlConventions); var html = tagGenerator.GenerateInputFor(MvcMockHelpers.MockViewContext(), accessor); Assert.AreEqual("<input type=\"text\" id=\"Name\" name=\"Name\" />", html.ToString()); }
public static HtmlTag Input <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, object> > expression) { var tag = new TagGenerator(HtmlConventionFactory.HtmlConventions); return(tag.GenerateInputFor(helper.ViewContext, expression)); }