diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/SelectTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/SelectTagHelper.cs index 92cab6b0e3..f650216b72 100644 --- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/SelectTagHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/SelectTagHelper.cs @@ -15,9 +15,11 @@ using Microsoft.AspNetCore.Razor.TagHelpers; namespace Microsoft.AspNetCore.Mvc.TagHelpers { /// - /// implementation targeting <select> elements with an asp-for attribute. + /// implementation targeting <select> elements with asp-for and/or + /// asp-items attribute(s). /// [HtmlTargetElement("select", Attributes = ForAttributeName)] + [HtmlTargetElement("select", Attributes = ItemsAttributeName)] public class SelectTagHelper : TagHelper { private const string ForAttributeName = "asp-for"; @@ -70,6 +72,13 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers throw new ArgumentNullException(nameof(context)); } + if (For == null) + { + // Informs contained elements that they're running within a targeted