Permalink
Browse files

Added Tag Helper example

  • Loading branch information...
Frank Quednau
Frank Quednau committed Aug 4, 2017
1 parent 7869e96 commit 7591aa5cdf08e2339a508240acc1d0ac8d23b5c2
Showing with 38 additions and 13 deletions.
  1. +24 −0 Stuff/TagHelpers.cs
  2. +12 −12 Views/Speaker/Create.cshtml
  3. +2 −1 Views/_ViewImports.cshtml
View
@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Razor.TagHelpers;
namespace MVC486.LayoutTagHelpers
{
public class RowTagHelper : TagHelper
{
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "div";
output.Attributes.SetAttribute("class", "row");
}
}
public class ColumnTagHelper : TagHelper
{
public string Size { get;set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
var colName = Size == "one" ? "column" : "columns";
output.TagName = "div";
output.Attributes.SetAttribute("class", $"{Size} {colName}");
}
}
}
@@ -7,24 +7,24 @@
<h1>Create a Speaker</h1>
<form asp-action="Create">
<div asp-validation-summary="All"></div>
<div class="row">
<div class="one column">
<row>
<column size="one">
<label asp-for="Name"></label>
<span asp-validation-for="Name"></span>
</div>
<div class="eight columns">
</column>
<column size="eight">
<input asp-for="Name" />
</div>
</div>
<div class="row">
<div class="one column">
</column>
</row>
<row>
<column size="one">
<label asp-for="EmailAddress"></label>
<span asp-validation-for="EmailAddress"></span>
</div>
<div class="eight columns">
</column>
<column size="eight">
<input asp-for="EmailAddress">
</div>
</div>
</column>
</row>
<p>
<input type="submit" value="Create" />
</p>
@@ -1 +1,2 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, MVC486

0 comments on commit 7591aa5

Please sign in to comment.