dotnet / dotnet/aspnetcore

Blazor: Support generating ID attributes based on the binding expression similar to how Name attributes are already generated

Open
#56,019 3 comments 0 reactions 0 assignees View on GitHub
area-blazor enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

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'm currently writing my first Blazor SSR application (coming from years of experience in ASP.NET Core MVC) and there's one thing that's worse than in MVC in my opinion: in MVC it's possible to generate IDs based on the model (e.g. `HtmlHelper.IdFor`) while it isn't (at least to my knowledge in Blazor). Blazor has a similar mechanism with the `ExpressionFormatter` & `HtmlFieldPrefix` but I would like to be able to use the same mechanism to also generate IDs additional to names on my input fields.

Why? Because I'd like to use `` element with a corresponding `` element, although that might be tricky, since depending on the consumer, it might be necessary to render those 2 elements in separate parts of the render tree (e.g. when using horizontal Bootstrap forms).

### 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.