static HtmlTag GenerateInputText <TModel> (TModel model, PropertyInfo member) { var modelValue = member.GetValue(model, null); if (modelValue == null) { return(null); } //<div class="control-group"> // <label class="control-label" for="Email">Email:</label> // <div class="controls"> // <input type="text" class="input-xlarge" data-val="true" // data-val-email="O e-mail digitado não é válido." // data-val-required="O campo E-mail é obrigatório." // id="Email" name="Email" value="@Model.Email"> // <span class="field-validation-valid error" data-valmsg-for="Email" // data-valmsg-replace="true"></span> // <p class="help-block">Ex.: [email protected]</p> // </div> //</div> var cg = CreateControlGroup(model, member); var input = new TextboxTag(member.Name, modelValue.ToString()) .Id(member.Name); FillValidation <TModel> (input, member); cg.Children [1].InsertFirst(input); return(cg); }
private void AddDateInput(string id) { var input = new TextboxTag() .Id(id) .Attr(HtmlAttributeConstants.Name, id); Child(input); }
public void mustache_value() { var tag = new TextboxTag(); tag.MustacheValue("prop"); tag.ToString().ShouldEqual("<input type=\"text\" value=\"{{prop}}\" />"); }
public void add_element_name_to_textbox() { var tag = new TextboxTag(); ElementRequest request = For(x => x.Address.City); request.ElementId = "AddressCity"; DefaultHtmlConventions.AddElementName(request, tag); tag.Attr("name").ShouldEqual("AddressCity"); }
public void replace_the_label() { var layout = new DefinitionListFieldChrome(); HtmlTag label = new HtmlTag("span").Text("some text"); layout.LabelTag = label; HtmlTag display = new TextboxTag().Attr("value", "something"); layout.LabelTag = display; layout.LabelTag.ShouldBeTheSameAs(display); }
public void do_not_overwrite_name_on_textbox_that_already_has_a_name() { var tag = new TextboxTag(); tag.Attr("name", "ExistingName"); var request = For(x => x.Address.City); request.ElementId = "AddressCity"; DefaultHtmlConventions.AddElementName(request, tag); tag.Attr("name").ShouldEqual("ExistingName"); }
public void write_to_string() { var layout = new DefinitionListFieldChrome(); HtmlTag label = new HtmlTag("span").Text("some text"); layout.LabelTag = label; HtmlTag display = new TextboxTag().Attr("value", "something"); layout.BodyTag = display; string html = layout.Render(); html.ShouldContain(label.ToString()); html.ShouldContain(display.ToString()); }
protected override void ConfigureDocument(HtmlDocument document) { var textbox = new TextboxTag(EmptyTextboxName, string.Empty) .Id(EmptyTextboxId) .Data("value", "some value"); document.Add(textbox); var button = new HtmlTag("button") .Id(DelayAddElementButtonId) .Text("Append element"); document.Add(button); var appendedElementsDiv = new DivTag().AddClass(AddedElementsClass); document.Add(appendedElementsDiv); document.ReferenceJavaScriptFile("file:///" + "jquery-2.0.3.min.js".ToFullPath()); document.AddJavaScript("$(function() { $('#" + DelayAddElementButtonId + "').click(function() { setTimeout(function() { $('." + AddedElementsClass + "').append('<p>blah</p>'); }, 3000); }); });"); }
static HtmlTag GenerateCalendar <TModel> (TModel model, PropertyInfo member) { var modelValue = member.GetValue(model, null); if (modelValue == null) { return(null); } //http://www.eyecon.ro/bootstrap-datepicker/ //<div class="control-group"> // <label class="control-label" for="Email">Email:</label> // <div class="controls"> //<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy"> //<input class="span2" size="16" type="text" value="12-02-2012"> //<span class="add-on"><i class="icon-th"></i></span> //</div> // <span class="field-validation-valid error" data-valmsg-for="Email" // data-valmsg-replace="true"></span> // <p class="help-block">Ex.: [email protected]</p> // </div> //</div> var cg = CreateControlGroup(model, member); var div = new DivTag().AddClass("datepicker"); var input = new TextboxTag(member.Name, modelValue.ToString()) .Id(member.Name); var span = new LiteralTag("span").AddClass("add-on"); div.Append(input); div.Append(span); FillValidation <TModel>(input, member); cg.Children[1].InsertFirst(input); return(cg); }
public void create_a_text_input_with_name_and_value() { var tag = new TextboxTag("firstname", "Lucas"); tag.ToString().ShouldEqual("<input type=\"text\" name=\"firstname\" value=\"Lucas\" />"); }
public void create_a_text_input_with_name_and_value() { var tag = new TextboxTag("firstname", "Lucas"); tag.ToString().ShouldEqual("<input type=\"text\" name=\"firstname\" value=\"Lucas\" />"); }