public void Should_be_able_to_Generate_a_File_Input_Button() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); string FileInput = htmlhelper.FileFor(P => P.fileFormat).ToString(); var cq = CQ.Create(FileInput); cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.File); }
public void Should_be_able_to_Generate_a_Reset_Button() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); string htmlTextBox = htmlhelper.ResetButton("SomeName").ToString(); var cq = CQ.Create(htmlTextBox); cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.RESET); }
public void Should_be_able_to_Generate_a_Hidden_Field_With_Model_And_Property() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); string FileInput = htmlhelper.Hidden(P => P.Name).ToString(); var cq = CQ.Create(FileInput); cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.HIDDEN); }
public void Should_be_able_to_Generate_a_Submit_Button() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); string submitButton = htmlhelper.Submit("SomeName").ToString(); var cq = CQ.Create(submitButton); cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.SUBMIT); }
public static ValidationBehavior ValidateOn(this FluentHtmlHelper html, string name) { if (!String.IsNullOrEmpty(name)) { return(new ValidationBehavior(() => GetModelState(html, name))); } return(null); }
public void Should_be_able_to_pass_in_the_Model_and_Property_and_Get_The_CheckBox() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); string htmlTextBox = htmlhelper.CheckBoxFor<Customer>(p => p.IsChecked).ToString(); var cq = CQ.Create(htmlTextBox); cq.Attr(HTMLATTRIBUTE.NAME).Should().Be("IsChecked"); cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.CHECKBOX); }
public void Should_be_able_to_pass_in_the_Model_and_Property_and_Get_The_Html_back() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); string htmlTextBox = htmlhelper.TextBoxFor<Customer>(p => p.Name).Disabled(true).Class("Required").ToString(); var cq = CQ.Create(htmlTextBox); cq.Attr(HTMLATTRIBUTE.NAME).Should().Be("Name"); cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be("text"); }
private static ModelState GetModelState(FluentHtmlHelper html, string name) { ModelState state; if (html.ViewData.ModelState.TryGetValue(name, out state)) { return(state); } return(null); }
public static ValidationMessage ValidationMessage(this FluentHtmlHelper html, string name) { ModelState state = GetModelState(html, name); string message = null; if (state != null && state.Errors != null && state.Errors.Count > 0) { message = GetUserErrorMessageOrDefault(html.ViewContext.HttpContext, state.Errors[0], state); } return(new ValidationMessage().Value(message)); }
public void Should_be_able_to_Create_A_Tag_with_the_Link() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); htmlhelper.Request = new HttpRequestMessage(); htmlhelper.Request.RequestUri = new Uri("http://localhost/api/home"); HttpConfiguration configuration = new HttpConfiguration(); htmlhelper.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = configuration; htmlhelper.Request.AddDefaultRoute(); string htmlanchortag = htmlhelper.Action<HomeController>(p => p.Get()).ToString(); var cq = CQ.Create(htmlanchortag); cq.Attr(HTMLATTRIBUTE.HREF).Should().Be("/api/home"); }
public void Should_be_able_Parse_the_RazorMVCtemplate_With_FluentTextboxHelper() { var templateConfiguration = new TemplateServiceConfiguration(); templateConfiguration.BaseTemplateType = typeof(MvcTemplate<>); templateConfiguration.Namespaces.Add("FluentHtml"); templateConfiguration.Namespaces.Add("FluentHtml.Intgeration"); templateConfiguration.EncodedStringFactory = new RawStringFactory(); using (var template = new TemplateService(templateConfiguration)) { FluentHtmlHelper<Customer> HTML = new FluentHtmlHelper<Customer>(); string inputTemplate = "@HTML.TextBoxFor(p => p.Name).Disabled(true);"; string output = template.Parse(inputTemplate, new Customer()); CQ.Create(output).Attr("name").Should().Be("Name"); } }
public void Should_be_able_to_pass_in_the_Model_and_Property_and_Get_The_RadioButton() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); string htmlTextBox = htmlhelper.RadioButtonFor<Customer>(p => p.IsChecked).ToString(); var cq = CQ.Create(htmlTextBox); cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.RADIO); }
public static Literal Literal(this FluentHtmlHelper html, string name) { return(new Literal().Value(String.IsNullOrEmpty(name) ? null : html.ViewData.Eval(name))); }
public void Should_be_able_to_pass_in_the_Model_and_Property_and_Get_The_Password() { FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>(); string htmlTextBox = htmlhelper.PasswordFor<Customer>(p => p.Name).ToString(); var cq = CQ.Create(htmlTextBox); cq.Attr(HTMLATTRIBUTE.NAME).Should().Be("Name"); cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.PASSWORD); }
public static TextArea TextArea(this FluentHtmlHelper html, string name) { return(new TextArea(name).Value(String.IsNullOrEmpty(name) ? null : html.ViewData.Eval(name)) .Do(ValidateOn(html, name))); }
public static SubmitButton SubmitButton(this FluentHtmlHelper html, string name) { return(new SubmitButton(name)); }
public static RadioButton RadioButton(this FluentHtmlHelper html, string name) { return(new RadioButton(name).SelectedValue(String.IsNullOrEmpty(name) ? null : html.ViewData.Eval(name))); }
public static CheckBox CheckBox(this FluentHtmlHelper html, string name) { return(new CheckBox(name).SelectedValue(String.IsNullOrEmpty(name) ? null : html.ViewData.Eval(name))); }
public static Literal Literal(this FluentHtmlHelper html) { return(new Literal()); }