EjsNumericTextBox Errors When Null - Ignores Data Validation

An example of the problem I'm encountering can be reproduced by running the code in this documentation in a dotnet core 3.1 app.


After copying and pasting the code, clicking submit works as expected.

However, if a user deletes the number and then presses submit again, the error below is output to the console and the app falls over.

What is more, if I step through the code, the bound view model value is the same as it was before clearing the number.

ejs.interop.min.js:1 System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.EJ2.Blazor.BaseComponent.updateProperty[T](String key, T publicValue, T privateValue, Object eventCallback, Expression`1 expression, Boolean isDataSource, Boolean isObservable)
   at Syncfusion.EJ2.Blazor.Inputs.EjsNumericTextBox`1.OnHybridParametersSet()
   at Syncfusion.EJ2.Blazor.Inputs.EjsNumericTextBox`1.OnParametersSetAsync()
   at Syncfusion.EJ2.Blazor.BaseComponent.UpdateModel(Dictionary`2 properties)
Error: System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.EJ2.Blazor.BaseComponent.updateProperty[T](String key, T publicValue, T privateValue, Object eventCallback, Expression`1 expression, Boolean isDataSource, Boolean isObservable)
   at Syncfusion.EJ2.Blazor.Inputs.EjsNumericTextBox`1.OnHybridParametersSet()
   at Syncfusion.EJ2.Blazor.Inputs.EjsNumericTextBox`1.OnParametersSetAsync()
   at Syncfusion.EJ2.Blazor.BaseComponent.UpdateModel(Dictionary`2 properties)

2 Replies

RO Robert February 23, 2020 11:15 AM UTC

For reference, the linked code, and just to be absolutely clear, the user has to enter a number, and then clear it before clicking 'Submit', which will cause the error:

@using System.ComponentModel.DataAnnotations
@using Syncfusion.EJ2.Blazor.Inputs

<EditForm Model="@User">
    <DataAnnotationsValidator />
    <div asp-validation-summary="All" class="text-danger"></div>
    <div class="form-group">
        <EjsNumericTextBox Placeholder='Enter value' @bind-Value="@User.ID"></EjsNumericTextBox>
        <ValidationMessage For="@(() => User.ID)" />
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
</EditForm>

@code {

    public Customer User = new Customer();

    public class Customer
    {
        [Required(ErrorMessage = "Value is required")]

        public int? ID { get; set; }

    }
}


PM Ponmani Murugaiyan Syncfusion Team February 24, 2020 09:43 AM UTC

Hi Robert,  
  
Greetings from Syncfusion support.   
   
We were able to replicate your reported problem. We have confirmed this as a bug at our end. We will fix and include the solution on our next week patch release, which is expected to be rolled out on February 25th, 2020. Please be patient until then.   
   
You can track the status of this problem by using the below feedback portal.   
   
   
Regards,   
Ponmani M 


Loader.
Up arrow icon