Setting minimum and maximum values for DxMaskedInput in Blazor

danielvogler3712

Daniel Vogler

Posted on February 7, 2023

Setting minimum and maximum values for DxMaskedInput in Blazor

Hellođź‘‹ fellow Blazor developers, I am seeking help with setting minimum and maximum values for DxMaskedInput tag in Blazor. I am currently using the following code:

<DxMaskedInput @bind-Value="@_dealSize"
               CssClass="cw-320"
               Mask="N2"
/>
Enter fullscreen mode Exit fullscreen mode

I want to set the minimum and maximum values for _dealSize, but I am encountering an error when trying to use the following code example that uses the ValueChanged event:

<DxMaskedInput Value="Value"
            ValueChanged="@((int newValue) => OnValueChanged(newValue))"
            Mask="@NumericMask.Currency">
</DxMaskedInput>
<DxButton Enabled="@IsEnabled">Update Value</DxButton>

@code {
    int Value = 0;
    bool IsEnabled = false;

    void OnValueChanged(int newValue)
    {
        Value = newValue;
        if (newValue != 0)
            IsEnabled = true;
        else IsEnabled = false;
    }
}
Enter fullscreen mode Exit fullscreen mode

The error I am encountering is:

{"EventId":111,"LogLevel":"Error","Category":"Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost",
"Message":"Unhandled exception in circuit \u0027WRZkSd3ggsKGlKKJZfwrV9sDpWQEmJjBFDRYdMjbsoc\u0027.",
"Exception":
"System.InvalidOperationException: 
DevExpress.Blazor.Internal.Editors.Models.MaskedInputModel requires a value for the \u0027ValueExpression\u0027 property. 
It is specified automatically when you use two-way binding(\u0027bind-Value\u0027).    at 
DevExpress.Blazor.Internal.Editors.Models.MaskedInputModel\u00601.CheckValueExpression()    at 
DevExpress.Blazor.Internal.Editors.Models.DataEditorModel\u00601.CreateFieldIdentifier()    at 
DevExpress.Blazor.Internal.Editors.Models.DataEditorModel\u00601.OnValidationStateChanged()    at 
DevExpress.Blazor.Internal.Editors.Models.DataEditorModel\u00601.ApplyParameterChanges()    at 
DevExpress.Blazor.Internal.ParameterTracker.EndUpdate()    at 
DevExpress.Blazor.Internal.Editors.Models.DataEditorModel\u00601.EndUpdate()    at 
DevExpress.Blazor.Base.DxDataEditor\u00601.SetParametersAsync(ParameterView parameters)",
"State":{"Message":"Unhandled exception in circuit \u0027WRZkSd3ggsKGlKKJZfwrV9sDpWQEmJjBFDRYdMjbsoc\u0027.",
"CircuitId":"WRZkSd3ggsKGlKKJZfwrV9sDpWQEmJjBFDRYdMjbsoc",
"{OriginalFormat}":"Unhandled exception in circuit \u0027{CircuitId}\u0027."}}
Enter fullscreen mode Exit fullscreen mode

If anyone has experience with this, I would greatly appreciate any help or suggestions. Thank you in advance!🙏

đź’– đź’Ş đź™… đźš©
danielvogler3712
Daniel Vogler

Posted on February 7, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related