DEV Community

Daniel Vogler
Daniel Vogler

Posted on

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!🙏

Top comments (0)

Create an Account! The only reason people scroll to the bottom...  
is because they want to read more.

Create an account to bookmark, comment, and react to articles that interest you.