Firstly, a big thank you for all of the work that everyone has put into the Blazor framework.
The InputNumber component does not support binding to properties of the long data type.
<EditForm Model="@Model">
<DataAnnotationsValidator/>
<ValidationSummary/>
<div class="form-group">
<label for="name">Name</label>
<InputText class="form-control" id="name" @bind-Value="@Model.Name"/>
<ValidationMessage For="@(() => Model.Name)"/>
</div>
<div class="form-group">
<label for="code">Code</label>
<InputNumber class="form-control" id="code" @bind-Value="@Model.Code"/>
<ValidationMessage For="@(() => Model.Code)"/>
</div>
<button class="btn btn-primary mdi mdi-content-save" type="submit">Save</button>
</EditForm>
@code
{
private Product Model { get; set; } = new Product();
public class Product
{
[Required] public string Name { get; set; }
[Required] public long Code { get; set; }
}
}
System.InvalidOperationException: The type 'System.Int64' is not a supported numeric type.
Based on this comment, the InputNumber component should support binding to the long type.
Looking through the code, the issue appears to be caused by the checks in this if statement.
If this is the case, then I am happy to create a fork to add targetType == typeof(long).
If applicable, add screenshots to help explain your problem.
Add any other context about the problem here.
Include the output of dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview8-013656
Commit: 8bf06ffc8d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18956
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\
Host (useful for support):
Version: 3.0.0-preview8-28405-07
Commit: d01b2fb7bc
.NET Core SDKs installed:
3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
@tnc1997 thanks for the issue report. We'll track fixing this for the next Blazor release.
I ran into this issue as well and checked the source code. Seems that it was simply missed in the type checking.
if (targetType == typeof(int) ||
targetType == typeof(float) ||
targetType == typeof(double) ||
targetType == typeof(decimal))
{
_stepAttributeValue = "any";
}
because the converter exists in the case statement.
case long @long:
return BindConverter.FormatValue(@long, CultureInfo.InvariantCulture);
Also I have noticed that several of the input components have some kind of issue with bindings different types. Would it not be better/easier to consolidate the value conversion into the base class and let it handle it for all the inputs?
Any reason why this isn't making it into 3.0?
I almost forgot, thanks @tnc1997! Your investigation made things a lot easier here.