dotnet / dotnet/aspnetcore

Add support for using "Label Templates" (like Display Templates and Editor Templates)

Open
#41,128 1 comment 0 reactions 0 assignees View on GitHub
area-mvc enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I work on a project with many custom `DisplayTemplates` and `EditorTemplates`. So far, the default label generated by using `LabelFor` has been sufficient for, but now I'd like to implement custom labels.

### Describe the solution you'd like

When using e.g. `@Html.LabelFor(x => x.MyProperty)`, where `MyProperty` is of type `MyModel`, I'd like for the the HtmlHelper to check if `~/Shared/LabelTemplates/MyModel.cshtml` exists and render that view instead of a default label. (Basically for `LabelFor` to behave just like `DisplayFor` and `EditorFor`.)

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.