React to the selfclosing support in TagHelpers

This commit is contained in:
ianhong 2015-02-20 09:16:04 -08:00
parent e6b75de0af
commit 4bb85eeaeb
32 changed files with 107 additions and 107 deletions

View File

@ -105,7 +105,6 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
output.MergeAttributes(tagBuilder); output.MergeAttributes(tagBuilder);
output.PostContent += tagBuilder.InnerHtml; output.PostContent += tagBuilder.InnerHtml;
output.SelfClosing = false;
} }
} }

View File

@ -203,10 +203,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
if (tagBuilder != null) if (tagBuilder != null)
{ {
// This TagBuilder contains the one <input/> element of interest. Since this is not the "checkbox" // This TagBuilder contains the one <input/> element of interest. Since this is not the "checkbox"
// special-case, output is a self-closing element and can merge the TagBuilder in directly. // special-case, output is a self-closing element no longer guarunteed.
output.MergeAttributes(tagBuilder); output.MergeAttributes(tagBuilder);
output.Content += tagBuilder.InnerHtml; output.Content += tagBuilder.InnerHtml;
output.SelfClosing = true;
} }
} }
} }
@ -240,7 +239,6 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
// Do not generate current element's attributes or tags. Instead put both <input type="checkbox"/> and // Do not generate current element's attributes or tags. Instead put both <input type="checkbox"/> and
// <input type="hidden"/> into the output's Content. // <input type="hidden"/> into the output's Content.
output.Attributes.Clear(); output.Attributes.Clear();
output.SelfClosing = false; // Otherwise Content will be ignored.
output.TagName = null; output.TagName = null;
output.Content += tagBuilder.ToString(TagRenderMode.SelfClosing); output.Content += tagBuilder.ToString(TagRenderMode.SelfClosing);

View File

@ -108,7 +108,6 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
output.MergeAttributes(tagBuilder); output.MergeAttributes(tagBuilder);
output.PostContent += tagBuilder.InnerHtml; output.PostContent += tagBuilder.InnerHtml;
output.SelfClosing = false;
} }
// Whether or not (not being highly unlikely) we generate anything, could update contained <option/> // Whether or not (not being highly unlikely) we generate anything, could update contained <option/>

View File

@ -49,7 +49,6 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
output.Content = tagBuilder.InnerHtml; output.Content = tagBuilder.InnerHtml;
output.MergeAttributes(tagBuilder); output.MergeAttributes(tagBuilder);
output.SelfClosing = false;
} }
} }
} }

View File

@ -18,6 +18,6 @@
</div> </div>
<div class="warehouse validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li> <div class="warehouse validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li>
</ul></div> </ul></div>
<input type="submit"></input> <input type="submit" />
</form></body> </form></body>
</html> </html>

View File

@ -41,7 +41,7 @@ Address_1</textarea>;
<input data-val="true" data-val-range="The field Number must be between 1 and 100." data-val-range-max="100" data-val-range-min="1" id="Employee_Number" name="Employee.Number" type="hidden" value="1" /> <input data-val="true" data-val-range="The field Number must be between 1 and 100." data-val-range-max="100" data-val-range-min="1" id="Employee_Number" name="Employee.Number" type="hidden" value="1" />
<div class="validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li> <div class="validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li>
</ul></div> </ul></div>
<input type="submit"></input> <input type="submit" />
</form> </form>
</body> </body>
</html> </html>

View File

@ -6,7 +6,7 @@
<title>Link</title> <title>Link</title>
<!-- Plain link tag --> <!-- Plain link tag -->
<link href="/site.css" rel="stylesheet"></link> <link href="/site.css" rel="stylesheet" />
<!-- Globbed link tag with existing file --> <!-- Globbed link tag with existing file -->
<link rel="stylesheet" href="/site.css" /> <link rel="stylesheet" href="/site.css" />
@ -15,10 +15,10 @@
<link rel="stylesheet" href="/site.css" /><link rel="stylesheet" href="/sub/site2.css" /> <link rel="stylesheet" href="/site.css" /><link rel="stylesheet" href="/sub/site2.css" />
<!-- Globbed link tag missing include --> <!-- Globbed link tag missing include -->
<link rel="stylesheet"></link> <link rel="stylesheet" />
<!-- Globbed link tag missing include but with static href --> <!-- Globbed link tag missing include but with static href -->
<link href="/site.css" rel="stylesheet"></link> <link href="/site.css" rel="stylesheet" />
<!-- Globbed link tag with missing file --> <!-- Globbed link tag with missing file -->
@ -66,13 +66,13 @@
<link href="/site.min.css" rel="stylesheet" data-extra="test" /> <link href="/site.min.css" rel="stylesheet" data-extra="test" />
<!-- Fallback with missing attribute --> <!-- Fallback with missing attribute -->
<link href="/site.min.css" rel="stylesheet" data-extra="test"></link> <link href="/site.min.css" rel="stylesheet" data-extra="test" />
<!-- Fallback with missing attribute --> <!-- Fallback with missing attribute -->
<link href="/site.min.css" rel="stylesheet" data-extra="test"></link> <link href="/site.min.css" rel="stylesheet" data-extra="test" />
<!-- Fallback with missing attribute --> <!-- Fallback with missing attribute -->
<link href="/site.min.css" rel="stylesheet" data-extra="test"></link> <link href="/site.min.css" rel="stylesheet" data-extra="test" />
</head> </head>
<body> <body>

View File

@ -79,7 +79,7 @@
<div class="order validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li> <div class="order validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li>
</ul></div> </ul></div>
<input type="hidden" id="Customer_Key" name="Customer.Key" value="KeyA" /> <input type="hidden" id="Customer_Key" name="Customer.Key" value="KeyA" />
<input type="submit"></input> <input type="submit" />
<input name="__RequestVerificationToken" type="hidden" value="{0}" /></form> <input name="__RequestVerificationToken" type="hidden" value="{0}" /></form>
</body> </body>
</html> </html>

View File

@ -17,7 +17,7 @@
<textarea rows="4" cols="50" class="product" id="Description" name="Description"> <textarea rows="4" cols="50" class="product" id="Description" name="Description">
Type the product description</textarea> Type the product description</textarea>
</div> </div>
<input type="submit"></input> <input type="submit" />
</form> </form>
</body> </body>
</html> </html>

View File

@ -55,6 +55,6 @@
<label class="product" for="z2__Description">Description</label> <label class="product" for="z2__Description">Description</label>
<textarea rows="4" cols="50" class="product" id="z2__Description" name="[2].Description"> <textarea rows="4" cols="50" class="product" id="z2__Description" name="[2].Description">
Product_2 description</textarea> Product_2 description</textarea>
</div> <input type="submit"></input> </div> <input type="submit" />
</form></body> </form></body>
</html> </html>

View File

@ -69,7 +69,7 @@
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-2 col-md-10"> <div class="col-md-offset-2 col-md-10">
<input class="btn btn-default" type="submit" value="Create"></input> <input class="btn btn-default" type="submit" value="Create" />
</div> </div>
</div> </div>
</div> </div>

View File

@ -67,7 +67,7 @@
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-2 col-md-10"> <div class="col-md-offset-2 col-md-10">
<input class="btn btn-default" type="submit" value="Create"></input> <input class="btn btn-default" type="submit" value="Create" />
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,8 +3,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"></meta> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>About - My ASP.NET Application</title> <title>About - My ASP.NET Application</title>
@ -45,7 +45,7 @@
<p><strong>Number of tags to show:</strong> 30</p> <p><strong>Number of tags to show:</strong> 30</p>
</section> </section>
</div> </div>
<hr></hr> <hr />
<footer> <footer>
</footer> </footer>

View File

@ -3,8 +3,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"></meta> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Help - My ASP.NET Application</title> <title>Help - My ASP.NET Application</title>
@ -37,7 +37,7 @@
<div> <div>
<p>Hello, you've reached the help page. If you're having troubles try visiting our <a href="/?approved=true">My Approved Home Page</a></p> <p>Hello, you've reached the help page. If you're having troubles try visiting our <a href="/?approved=true">My Approved Home Page</a></p>
</div> </div>
<hr></hr> <hr />
<footer> <footer>
</footer> </footer>

View File

@ -3,8 +3,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"></meta> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Home Page - My ASP.NET Application</title> <title>Home Page - My ASP.NET Application</title>
@ -55,7 +55,7 @@
</div> </div>
<hr></hr> <hr />
<footer> <footer>

View File

@ -45,7 +45,7 @@ namespace Asp
BeginContext(120, 2, true); BeginContext(120, 2, true);
WriteLiteral("\r\n"); WriteLiteral("\r\n");
EndContext(); EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", "test", async() => { __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", true, "test", async() => {
} }
, StartWritingScope, EndWritingScope); , StartWritingScope, EndWritingScope);
__Microsoft_AspNet_Mvc_Razor_InputTestTagHelper = CreateTagHelper<Microsoft.AspNet.Mvc.Razor.InputTestTagHelper>(); __Microsoft_AspNet_Mvc_Razor_InputTestTagHelper = CreateTagHelper<Microsoft.AspNet.Mvc.Razor.InputTestTagHelper>();
@ -77,7 +77,7 @@ __Microsoft_AspNet_Mvc_Razor_InputTestTagHelper.For = CreateModelExpression(__mo
BeginContext(146, 2, true); BeginContext(146, 2, true);
WriteLiteral("\r\n"); WriteLiteral("\r\n");
EndContext(); EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", "test", async() => { __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", true, "test", async() => {
} }
, StartWritingScope, EndWritingScope); , StartWritingScope, EndWritingScope);
__Microsoft_AspNet_Mvc_Razor_InputTestTagHelper = CreateTagHelper<Microsoft.AspNet.Mvc.Razor.InputTestTagHelper>(); __Microsoft_AspNet_Mvc_Razor_InputTestTagHelper = CreateTagHelper<Microsoft.AspNet.Mvc.Razor.InputTestTagHelper>();

View File

@ -123,6 +123,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
// Assert // Assert
Assert.Equal("form", output.TagName); Assert.Equal("form", output.TagName);
Assert.False(output.SelfClosing);
Assert.Empty(output.Attributes); Assert.Empty(output.Attributes);
Assert.Empty(output.PreContent); Assert.Empty(output.PreContent);
Assert.Empty(output.Content); Assert.Empty(output.Content);
@ -185,6 +186,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
await formTagHelper.ProcessAsync(context, output); await formTagHelper.ProcessAsync(context, output);
Assert.Equal("form", output.TagName); Assert.Equal("form", output.TagName);
Assert.False(output.SelfClosing);
var attribute = Assert.Single(output.Attributes); var attribute = Assert.Single(output.Attributes);
Assert.Equal(expectedAttribute, attribute); Assert.Equal(expectedAttribute, attribute);
Assert.Empty(output.PreContent); Assert.Empty(output.PreContent);
@ -225,6 +227,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
generator.Verify(); generator.Verify();
Assert.Equal("form", output.TagName); Assert.Equal("form", output.TagName);
Assert.False(output.SelfClosing);
Assert.Empty(output.Attributes); Assert.Empty(output.Attributes);
Assert.Empty(output.PreContent); Assert.Empty(output.PreContent);
Assert.Empty(output.Content); Assert.Empty(output.Content);
@ -308,6 +311,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
// Assert // Assert
Assert.Equal("form", output.TagName); Assert.Equal("form", output.TagName);
Assert.False(output.SelfClosing);
var attribute = Assert.Single(output.Attributes); var attribute = Assert.Single(output.Attributes);
Assert.Equal(new KeyValuePair<string, string>("aCTiON", "my-action"), attribute); Assert.Equal(new KeyValuePair<string, string>("aCTiON", "my-action"), attribute);
Assert.Empty(output.PreContent); Assert.Empty(output.PreContent);

View File

@ -134,7 +134,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
Assert.Equal(expectedPreContent, output.PreContent); Assert.Equal(expectedPreContent, output.PreContent);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.Equal(expectedPostContent, output.PostContent); Assert.Equal(expectedPostContent, output.PostContent);
Assert.True(output.SelfClosing); Assert.False(output.SelfClosing);
Assert.Equal(expectedTagName, output.TagName); Assert.Equal(expectedTagName, output.TagName);
} }
@ -199,7 +199,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
Assert.Equal(expectedPreContent, output.PreContent); Assert.Equal(expectedPreContent, output.PreContent);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.Equal(expectedPostContent, output.PostContent); Assert.Equal(expectedPostContent, output.PostContent);
Assert.False(output.SelfClosing); Assert.True(output.SelfClosing);
Assert.Null(output.TagName); // Cleared Assert.Null(output.TagName); // Cleared
} }
@ -281,11 +281,11 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
// Assert // Assert
htmlGenerator.Verify(); htmlGenerator.Verify();
Assert.False(output.SelfClosing);
Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedAttributes, output.Attributes);
Assert.Equal(expectedPreContent, output.PreContent); Assert.Equal(expectedPreContent, output.PreContent);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.Equal(expectedPostContent, output.PostContent); Assert.Equal(expectedPostContent, output.PostContent);
Assert.True(output.SelfClosing);
Assert.Equal(expectedTagName, output.TagName); Assert.Equal(expectedTagName, output.TagName);
} }
@ -366,11 +366,11 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
// Assert // Assert
htmlGenerator.Verify(); htmlGenerator.Verify();
Assert.False(output.SelfClosing);
Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedAttributes, output.Attributes);
Assert.Equal(expectedPreContent, output.PreContent); Assert.Equal(expectedPreContent, output.PreContent);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.Equal(expectedPostContent, output.PostContent); Assert.Equal(expectedPostContent, output.PostContent);
Assert.True(output.SelfClosing);
Assert.Equal(expectedTagName, output.TagName); Assert.Equal(expectedTagName, output.TagName);
} }
@ -450,11 +450,11 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
// Assert // Assert
htmlGenerator.Verify(); htmlGenerator.Verify();
Assert.False(output.SelfClosing);
Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedAttributes, output.Attributes);
Assert.Equal(expectedPreContent, output.PreContent); Assert.Equal(expectedPreContent, output.PreContent);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.Equal(expectedPostContent, output.PostContent); Assert.Equal(expectedPostContent, output.PostContent);
Assert.True(output.SelfClosing);
Assert.Equal(expectedTagName, output.TagName); Assert.Equal(expectedTagName, output.TagName);
} }
@ -548,11 +548,11 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
// Assert // Assert
htmlGenerator.Verify(); htmlGenerator.Verify();
Assert.False(output.SelfClosing);
Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedAttributes, output.Attributes);
Assert.Equal(expectedPreContent, output.PreContent); Assert.Equal(expectedPreContent, output.PreContent);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.Equal(expectedPostContent, output.PostContent); Assert.Equal(expectedPostContent, output.PostContent);
Assert.True(output.SelfClosing);
Assert.Equal(expectedTagName, output.TagName); Assert.Equal(expectedTagName, output.TagName);
} }

View File

@ -225,11 +225,11 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
await tagHelper.ProcessAsync(tagHelperContext, output); await tagHelper.ProcessAsync(tagHelperContext, output);
// Assert // Assert
Assert.True(output.SelfClosing);
Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedAttributes, output.Attributes);
Assert.Equal(expectedPreContent, output.PreContent); Assert.Equal(expectedPreContent, output.PreContent);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.Equal(expectedPostContent, output.PostContent); Assert.Equal(expectedPostContent, output.PostContent);
Assert.False(output.SelfClosing);
Assert.Equal(expectedTagName, output.TagName); Assert.Equal(expectedTagName, output.TagName);
Assert.NotNull(viewContext.FormContext?.FormData); Assert.NotNull(viewContext.FormContext?.FormData);
@ -313,11 +313,11 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
await tagHelper.ProcessAsync(tagHelperContext, output); await tagHelper.ProcessAsync(tagHelperContext, output);
// Assert // Assert
Assert.True(output.SelfClosing);
Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedAttributes, output.Attributes);
Assert.Equal(expectedPreContent, output.PreContent); Assert.Equal(expectedPreContent, output.PreContent);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.Equal(expectedPostContent, output.PostContent); Assert.Equal(expectedPostContent, output.PostContent);
Assert.False(output.SelfClosing);
Assert.Equal(expectedTagName, output.TagName); Assert.Equal(expectedTagName, output.TagName);
Assert.NotNull(viewContext.FormContext?.FormData); Assert.NotNull(viewContext.FormContext?.FormData);

View File

@ -136,9 +136,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
await tagHelper.ProcessAsync(tagHelperContext, output); await tagHelper.ProcessAsync(tagHelperContext, output);
// Assert // Assert
Assert.True(output.SelfClosing);
Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedAttributes, output.Attributes);
Assert.Equal(expectedContent, output.Content); Assert.Equal(expectedContent, output.Content);
Assert.False(output.SelfClosing);
Assert.Equal(expectedTagName, output.TagName); Assert.Equal(expectedTagName, output.TagName);
} }

View File

@ -11,16 +11,16 @@
@using (Html.BeginForm("CreateWarehouse", "MvcTagHelper_Home")) @using (Html.BeginForm("CreateWarehouse", "MvcTagHelper_Home"))
{ {
<div> <div>
<label asp-for="City" class="warehouse" /> <label asp-for="City" class="warehouse"></label>
<input asp-for="City" type="text" size="50" /> <input asp-for="City" type="text" size="50" />
<span asp-validation-for="City" /> <span asp-validation-for="City"></span>
</div> </div>
<div> <div>
<label asp-for="Product" class="warehouse" /> <label asp-for="Product" class="warehouse"></label>
<select asp-for="Product" asp-items="(IEnumerable<SelectListItem>)ViewBag.Items" /> <select asp-for="Product" asp-items="(IEnumerable<SelectListItem>)ViewBag.Items"></select>
<span asp-validation-for="Product" /> <span asp-validation-for="Product"></span>
</div> </div>
<div asp-validation-summary="ValidationSummary.All" class="warehouse" /> <div asp-validation-summary="ValidationSummary.All" class="warehouse"></div>
<input type="submit" /> <input type="submit" />
} }
</body> </body>

View File

@ -8,26 +8,26 @@
<input asp-for="Number" type="number" class="form-control" /> <input asp-for="Number" type="number" class="form-control" />
</div> </div>
<div> <div>
<label asp-for="Name" class="employee" /> <label asp-for="Name" class="employee"></label>
@Html.TextAreaFor(m => m.Name) @Html.TextAreaFor(m => m.Name)
</div> </div>
<div> <div>
<label asp-for="PhoneNumber" class="employee" /> <label asp-for="PhoneNumber" class="employee"></label>
<input asp-for="PhoneNumber" type="tel" /> <input asp-for="PhoneNumber" type="tel" />
</div> </div>
<div> <div>
@{ @{
var genders = new SelectList(new string[] { "Male", "Female" }); var genders = new SelectList(new string[] { "Male", "Female" });
} }
<label asp-for="Gender" class="employee" /> <label asp-for="Gender" class="employee"></label>
<select asp-for="Gender" asp-items="genders" /> <select asp-for="Gender" asp-items="genders"></select>
</div> </div>
<div> <div>
<label asp-for="Remote" class="employee" /> <label asp-for="Remote" class="employee"></label>
@Html.CheckBoxFor(m=>m.Remote) @Html.CheckBoxFor(m=>m.Remote)
</div> </div>
<div> <div>
<label asp-for="OfficeNumber" class="employee" /> <label asp-for="OfficeNumber" class="employee"></label>
@{ @{
var offices = new SelectList(new string[] {"1001","1002"}); var offices = new SelectList(new string[] {"1001","1002"});
} }

View File

@ -20,67 +20,67 @@
<body> <body>
<form asp-controller="MvcTagHelper_Order" asp-action="Submit" asp-anti-forgery=" true"> <form asp-controller="MvcTagHelper_Order" asp-action="Submit" asp-anti-forgery=" true">
<div> <div>
<label asp-for="Shipping" class="order" /> <label asp-for="Shipping" class="order"></label>
<input asp-for="Shipping" type="text" asp-format="Your shipping method is {0}" size="50" /> <input asp-for="Shipping" type="text" asp-format="Your shipping method is {0}" size="50" />
</div> </div>
<div> <div>
<label asp-for="ShippingDateTime" class="order" /> <label asp-for="ShippingDateTime" class="order"></label>
<input asp-for="ShippingDateTime" type="datetime-local" /> <input asp-for="ShippingDateTime" type="datetime-local" />
</div> </div>
<div> <div>
<label asp-for="Products" class="order" /> <label asp-for="Products" class="order"></label>
@{ var @object = "multiple"; } @{ var @object = "multiple"; }
<select asp-for="@Model.Products" asp-items="@((IEnumerable<SelectListItem>)ViewBag.Items)" multiple="@(@object)" /> <select asp-for="@Model.Products" asp-items="@((IEnumerable<SelectListItem>)ViewBag.Items)" multiple="@(@object)"></select>
</div> </div>
<div> <div>
<label asp-for="SubstituteProducts" class="order" /> <label asp-for="SubstituteProducts" class="order"></label>
@* Use same select list as Products. Selection when Products is non-null is not used here. *@ @* Use same select list as Products. Selection when Products is non-null is not used here. *@
<select asp-for="SubstituteProducts" asp-items="@((IEnumerable<SelectListItem>)ViewBag.Items)" /> <select asp-for="SubstituteProducts" asp-items="@((IEnumerable<SelectListItem>)ViewBag.Items)"></select>
</div> </div>
<div> <div>
<label asp-for="OrderDate" class="order" /> <label asp-for="OrderDate" class="order"></label>
<input asp-for="OrderDate" type="datetime" asp-format="{0:yyyy/MM/dd/ g}" /> <input asp-for="OrderDate" type="datetime" asp-format="{0:yyyy/MM/dd/ g}" />
</div> </div>
<div> <div>
<label asp-for="NeedSpecialHandle" class="order" /> <label asp-for="NeedSpecialHandle" class="order"></label>
<input asp-for="NeedSpecialHandle" type="checkbox" /> <input asp-for="NeedSpecialHandle" type="checkbox" />
</div> </div>
<div> <div>
<label asp-for="PaymentMethod" class="order" /> <label asp-for="PaymentMethod" class="order"></label>
<select asp-for="PaymentMethod"> <select asp-for="PaymentMethod">
<option value="Credit">Credit</option> <option value="Credit">Credit</option>
<option value="Check">Check</option> <option value="Check">Check</option>
</select> </select>
</div> </div>
<div> <div>
<label asp-for="Customer.Number" class="order" /> <label asp-for="Customer.Number" class="order"></label>
<input asp-for="Customer.Number" type="number" class="form-control" /> <input asp-for="Customer.Number" type="number" class="form-control" />
<span asp-validation-for="Customer.Number" /> <span asp-validation-for="Customer.Number"></span>
</div> </div>
<div> <div>
<label asp-for="Customer.Name" class="order" /> <label asp-for="Customer.Name" class="order"></label>
<input asp-for="Customer.Name" type="text" /> <input asp-for="Customer.Name" type="text" />
</div> </div>
<div> <div>
<label asp-for="Customer.Email" class="order" /> <label asp-for="Customer.Email" class="order"></label>
<input asp-for="Customer.Email" type="email" /> <input asp-for="Customer.Email" type="email" />
<span asp-validation-for="Customer.Email" /> <span asp-validation-for="Customer.Email"></span>
</div> </div>
<div> <div>
<label asp-for="Customer.PhoneNumber" class="order" /> <label asp-for="Customer.PhoneNumber" class="order"></label>
<input asp-for="Customer.PhoneNumber" type="tel" /> <input asp-for="Customer.PhoneNumber" type="tel" />
</div> </div>
<div> <div>
<label asp-for="Customer.Password" class="order" /> <label asp-for="Customer.Password" class="order"></label>
<input asp-for="Customer.Password" type="password" class="form-control" /> <input asp-for="Customer.Password" type="password" class="form-control" />
<span asp-validation-for="Customer.Password" /> <span asp-validation-for="Customer.Password"></span>
</div> </div>
<div> <div>
<label asp-for="Customer.Gender" class="order" /> <label asp-for="Customer.Gender" class="order"></label>
@Html.EditorFor(model => model.Customer.Gender) @Html.EditorFor(model => model.Customer.Gender)
<span asp-validation-for="Customer.Gender" /> <span asp-validation-for="Customer.Gender"></span>
</div> </div>
<div asp-validation-summary="ValidationSummary.All" class="order" /> <div asp-validation-summary="ValidationSummary.All" class="order"></div>
<input type="hidden" asp-for="Customer.Key" /> <input type="hidden" asp-for="Customer.Key" />
<input type="submit" /> <input type="submit" />
</form> </form>

View File

@ -14,12 +14,12 @@
<body> <body>
<form asp-controller="MvcTagHelper_Home" asp-route-action="ProductSubmit" asp-anti-forgery="false" method="get"> <form asp-controller="MvcTagHelper_Home" asp-route-action="ProductSubmit" asp-anti-forgery="false" method="get">
<div> <div>
<label asp-for="HomePage" class="product" /> <label asp-for="HomePage" class="product"></label>
<input asp-for="HomePage" type="url" size="50" /> <input asp-for="HomePage" type="url" size="50" />
</div> </div>
<div> <div>
<label asp-for="Description" class="product" /> <label asp-for="Description" class="product"></label>
<textarea asp-for="Description" rows="4" cols="50" class="product" /> <textarea asp-for="Description" rows="4" cols="50" class="product"></textarea>
</div> </div>
<input type="submit" /> <input type="submit" />
</form> </form>

View File

@ -17,7 +17,7 @@
@* Update HtmlFieldPrefix so generated for, id and name attribute values are correct. *@ @* Update HtmlFieldPrefix so generated for, id and name attribute values are correct. *@
ViewData.TemplateInfo.HtmlFieldPrefix = fieldPrefix + string.Format("[{0}]", index++); ViewData.TemplateInfo.HtmlFieldPrefix = fieldPrefix + string.Format("[{0}]", index++);
<div> <div>
<label asp-for="@(model.HomePage)" class="product" /> <label asp-for="@(model.HomePage)" class="product"></label>
<input asp-for="@(model.HomePage)" type="url" size="50" disabled="disabled" readonly="readonly" /> <input asp-for="@(model.HomePage)" type="url" size="50" disabled="disabled" readonly="readonly" />
</div> </div>
@await Html.PartialAsync("_ProductPartial", model) @await Html.PartialAsync("_ProductPartial", model)

View File

@ -3,14 +3,14 @@
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" @addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
<div> <div>
<label asp-for="Number" class="product" /> <label asp-for="Number" class="product"></label>
<input asp-for="Number" type="number"/> <input asp-for="Number" type="number"/>
</div> </div>
<div> <div>
<label asp-for="ProductName" class="product" /> <label asp-for="ProductName" class="product"></label>
<input asp-for="ProductName" type="text"/> <input asp-for="ProductName" type="text"/>
</div> </div>
<div> <div>
<label asp-for="Description" class="product" /> <label asp-for="Description" class="product"></label>
<textarea asp-for="Description" rows="4" cols="50" class="product" /> <textarea asp-for="Description" rows="4" cols="50" class="product"></textarea>
</div> </div>

View File

@ -10,37 +10,37 @@
<body> <body>
<form asp-route-area="Customer" asp-controller="MvcTagHelper_Customer" asp-action="Index"> <form asp-route-area="Customer" asp-controller="MvcTagHelper_Customer" asp-action="Index">
<div> <div>
<label asp-for="Number" class="order" /> <label asp-for="Number" class="order"></label>
<input asp-for="Number" type="number" class="form-control" /> <input asp-for="Number" type="number" class="form-control" />
<span asp-validation-for="Number" /> <span asp-validation-for="Number"></span>
</div> </div>
<div> <div>
<label asp-for="Name" class="order" /> <label asp-for="Name" class="order"></label>
<input asp-for="Name" type="text" /> <input asp-for="Name" type="text" />
</div> </div>
<div> <div>
<label asp-for="Email" class="order" /> <label asp-for="Email" class="order"></label>
<input asp-for="Email" type="email" /> <input asp-for="Email" type="email" />
<span asp-validation-for="Email" /> <span asp-validation-for="Email"></span>
</div> </div>
<div> <div>
<label asp-for="PhoneNumber" class="order" /> <label asp-for="PhoneNumber" class="order"></label>
<input asp-for="PhoneNumber" type="tel" /> <input asp-for="PhoneNumber" type="tel" />
</div> </div>
<div> <div>
<label asp-for="Password" class="order" /> <label asp-for="Password" class="order"></label>
<input asp-for="Password" type="password" class="form-control" /> <input asp-for="Password" type="password" class="form-control" />
<span asp-validation-for="Password" /> <span asp-validation-for="Password"></span>
</div> </div>
<div> <div>
<label asp-for="Gender" class="order" /> <label asp-for="Gender" class="order"></label>
<input asp-for="Gender" type="radio" value="Male" /> Male <input asp-for="Gender" type="radio" value="Male" /> Male
<input asp-for="Gender" type="radio" value="Female" /> Female <input asp-for="Gender" type="radio" value="Female" /> Female
<span asp-validation-for="Gender" /> <span asp-validation-for="Gender"></span>
</div> </div>
<div asp-validation-summary="ValidationSummary.All" class="order" /> <div asp-validation-summary="ValidationSummary.All" class="order"></div>
<div asp-validation-summary="ValidationSummary.ModelOnly" class="order" /> <div asp-validation-summary="ValidationSummary.ModelOnly" class="order"></div>
<input type="submit" /> <input type="submit"></input>
</form> </form>
</body> </body>
</html> </html>

View File

@ -23,6 +23,7 @@ namespace TagHelpersWebSite.TagHelpers
Info.CopyrightYear.ToString(), Info.CopyrightYear.ToString(),
Info.Approved.ToString(), Info.Approved.ToString(),
Info.TagsToShow.ToString()); Info.TagsToShow.ToString());
output.SelfClosing = false;
} }
} }
} }

View File

@ -25,47 +25,47 @@
<div asp-validation-summary="ValidationSummary.All" class="text-danger"> <div asp-validation-summary="ValidationSummary.All" class="text-danger">
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="Age" class="control-label col-md-2" /> <label asp-for="Age" class="control-label col-md-2"></label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="Age" class="form-control" /> <input asp-for="Age" class="form-control" />
<span asp-validation-for="Age" /> <span asp-validation-for="Age"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="Email" class="control-label col-md-2" /> <label asp-for="Email" class="control-label col-md-2"></label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="Email" class="form-control" /> <input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" /> <span asp-validation-for="Email"></span>
</div> </div>
</div> </div>
<input type="hidden" asp-for="EmployeeId" value="0" /> <input type="hidden" asp-for="EmployeeId" value="0" />
<div class="form-group"> <div class="form-group">
<label asp-for="FullName" class="control-label col-md-2" /> <label asp-for="FullName" class="control-label col-md-2"></label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="FullName" class="form-control" /> <input asp-for="FullName" class="form-control" />
<span asp-validation-for="FullName" /> <span asp-validation-for="FullName"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="Gender" class="control-label col-md-2" /> <label asp-for="Gender" class="control-label col-md-2"></label>
<div class="col-md-10"> <div class="col-md-10">
<input type="radio" asp-for="Gender" value="M" /> Male <input type="radio" asp-for="Gender" value="M" /> Male
<input type="radio" asp-for="Gender" value="F" /> Female <input type="radio" asp-for="Gender" value="F" /> Female
<span asp-validation-for="Gender" /> <span asp-validation-for="Gender"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="JoinDate" class="control-label col-md-2" /> <label asp-for="JoinDate" class="control-label col-md-2"></label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="JoinDate" class="form-control" /> <input asp-for="JoinDate" class="form-control" />
<span asp-validation-for="JoinDate" /> <span asp-validation-for="JoinDate"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="Salary" class="control-label col-md-2" /> <label asp-for="Salary" class="control-label col-md-2"></label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="Salary" class="form-control" /> <input asp-for="Salary" class="form-control" />
<span asp-validation-for="Salary" /> <span asp-validation-for="Salary"></span>
</div> </div>
</div> </div>

View File

@ -15,5 +15,5 @@
Version = new Version(1, 1), Version = new Version(1, 1),
CopyrightYear = 1990, CopyrightYear = 1990,
Approved = true, Approved = true,
TagsToShow = 30 }" /> TagsToShow = 30 }"/>
</div> </div>

View File

@ -1,7 +1,7 @@
@{ @{
Layout = null; Layout = null;
} }
<root /> <root></root>
<nested>some-content</nested> <nested>some-content</nested>

View File

@ -1,2 +1,2 @@
layout:<root/> layout:<root></root>
@RenderBody() @RenderBody()