Skip to content

[Blazor] null in select element #23934

Open

Description

@mrpmorris

With regards to this PR: #23221

Instead of assuming an empty string and null are the same for an input,...

Would it be possible to set a marker attribute on the when we try to set the value to @null, and in the Blazor code detect that and use null for the @onchange event and binding?

<option value=@null>Select one... </option>

Would generate something like

<option bl_somethingunique>Select one... </>

Due to HTML limitations we wouldn't be able to have an empty string and a null as available values in the same select, but at least the C# developer won't have to write some code to convert "" to null, and it will "just work".

Activity

  1. added
    area-blazor
    enhancement
    on Jul 14, 2020
  2. added this to the Backlog milestone on Jul 15, 2020
  3. mkArtakMSFT commented on Jul 15, 2020

    @mkArtakMSFT
    Contributor

    We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

  4. added
    affected-few
    severity-minor
    on Oct 7, 2020
  5. added
    feature-blazor-component-model
    feature-rendering
    on Apr 20, 2021
  6. added
    Priority:3
    on Oct 22, 2021
  7. 2 remaining items

  8. Deadvi5 commented on Jan 9, 2024

    @Deadvi5

    We've encountered this "issue". I'm commenting just to show interest in this and to get notifications 😄

  9. linuspetrucci commented on Dec 12, 2025

    @linuspetrucci

    I recently ran into a situation where this would have been very handy. I am definetly interested in this feature.

  10. kgar commented on Sep 15, 2026

    @kgar

    My team works on a forms-heavy family of enterprise applications, so this comes up every now and then. When a field is required, we've resorted to using the RequiredAttribute option AllowEmptyStrings = false. It would be a nice-to-have, for sure.

  11. self-assigned this
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Pillar: Dev ExperiencePriority:3affected-fewarea-blazorenhancementfeature-blazor-component-modelfeature-renderingseverity-minor

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions