Get string property name in Display Template view ( Html.Display("Property1") )
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
I'm trying to use Display html helpers, and they would be a lot more useful If I could get the property name in the .cshtml template view.
Example:
```
@Html.DisplayFor(o => o.FirstName)
```
and `String.cshtml`
```
@model string
@{
Layout = "_DisplayFieldLayout";
}
@Model
```
`_DisplayFieldLayout.cshtml`
```
@Html.Label("", null) @* get property name here so instead of null I could pass MyFunc(propName) *@
...
@RenderBody()
```
### Describe the solution you'd like
be able to get the display property name string value in the display helper view
Contributor guide
Research direction
Start with the String.cshtml display template and _DisplayFieldLayout.cshtml example, then trace how Html.DisplayFor(o => o.FirstName) supplies information to the template. Determine whether the display property name is available in the current view context and identify the framework area where exposing it would belong. Done means the template or layout can reliably access the property name for the requested display expression.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100