Questions tagged [tag-helpers]

ASP.NET Core MVC TagHelpers are server-sided classes used for rendering HTML content. They react to specific HTML tags or attributes within the razor views, and can alter and generate new markup. They're a modern alternative to the ASP.NET MVC Html Helpers.

ASP.NET Core MVC TagHelpers enable server-sided code for rendering additional HTML content in Razor View templates, like validation or rendering commonly used components.

Unlike Html Helper calls, the TagHelpers are html friendly and better blends in the Razor HTML templates.

Official ASP.NET Core TagHelper Documentation

346 questions
188
votes
6 answers

Select Tag Helper in ASP.NET Core MVC

I need some help with the select tag helper in ASP.NET Core. I have a list of employees that I'm trying to bind to a select tag helper. My employees are in a List EmployeesList and selected value will go into EmployeeId property. My view…
Sam
  • 19,814
  • 35
  • 141
  • 272
126
votes
4 answers

How to add link parameter to asp tag helpers in ASP.NET Core MVC

I have a lot of experience with ASP.NET MVC 1-5. Now I learn ASP.NET Core MVC and have to pass a parameter to link in page. For example I have the following Action [HttpGet] public ActionResult GetProduct(string id) { ViewBag.CaseId = id; …
Elvin Mammadov
  • 17,572
  • 9
  • 34
  • 76
66
votes
4 answers

TagHelper for passing route values as part of a link

When specifying asp-controller and asp-action on a link, what's the syntax for also passing an id attribute? E.g. If I wanted to link to the edit URL for a given object, the required URL would be /user/edit/5 for example. Is there a method to…
mattdwen
  • 4,878
  • 10
  • 44
  • 60
40
votes
4 answers

Set Default/Null Value with Select TagHelper

In asp.net mvc you can use: @Html.DropDownListFor(model => model.Category, ViewBag.Category as IEnumerable, "-- SELECT --", new { @class = "form-control" }) Using asp.net 5, how do I include the default or null value (-- SELECT --) …
Reafidy
  • 7,918
  • 4
  • 42
  • 74
38
votes
4 answers

asp.net conditionally disable a tag helper (textarea)

I want to enable or disable a textarea depending on a condition that evalueates from the model, and I am using the textarea tag helper. In other words, something like this: