Skip to content

Blazor - Model Binding InputText and String #40785

@casper7526

Description

@casper7526

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Public string? X

Bind the string to an InputText, post the form. X is null.
Type something into the field than delete the text, post the string. X is now an empty string.

Work around was just adding a check on my setter but the fact that an empty text box can represent both null and empty string is not clear.

Expected Behavior

String should always be null when blank except when explicitly told otherwise.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions