Skip to content

[Blazor] null in select element #23934

Open
@mrpmorris

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pillar: Dev ExperiencePriority:3Work that is nice to haveaffected-fewThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-component-modelAny feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc)feature-renderingFeatures dealing with how blazor renders componentsseverity-minorThis label is used by an internal tool

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions