I have an Code39 barcode generator with Value bounded to textbox, but when I type unhandled characters []/, the program halts and OnValidationFailed never gets called. Am I suppose to bind textbox in a different way?
<SfBarcodeGenerator @ref="SfBarcodeGenerator" Width="@Width.ToString()" Height="@Height.ToString()" OnValidationFailed="@OnValidationFailed" Type="@BarcodeType.Code39" Value="@BarcodeValue">
<BarcodeGeneratorDisplayText Text="@_barcodeDisplayText"></BarcodeGeneratorDisplayText>
</SfBarcodeGenerator>
Hi Sivakumar
Yes, your demo works on Blazor Server, but for Blazor WASM it does not work. The OnValidationFailed event gets called indefinitely causing the app to hang.
To reproduce create a Blazor WASM project with the exact sample code you provided. You will see that the alert gets called multiple times until the app crashes. This issue is present in Blazor WASM ASP.NET Hosted too.
I have added WASM project to your example for reference.
Hi Sivakumar, any update on this?
|
public void OnValidationFailed(ValidationFailedEventArgs args)
{
Console.WriteLine(args.Message);
} |
Hi Aravind,
I understand that an alert blocks thread and after dismissal gets rerendered, but with Console.WriteLine it still is getting rerendered and calling OnValidationFailed infinitely.
Perhaps the issue is how I am using SfBarcodeGenerator? I have a TextBox value bounded to BarcodeValue. Then SfBarcodeGenerator Value bounded to BarcodeValue. When I change the TextBox value the barcode generates fine, but invalid values cause OnValidationFailed to be called infinitely until the app crashes.
See code:
SfBarcodeGenerator SfBarcodeGenerator;
public string BarcodeValue = "012345678911";
<SfTextBox @bind-Value="@BarcodeValue" Multiline="true"></SfTextBox>
<SfBarcodeGenerator @ref="SfBarcodeGenerator" OnValidationFailed="@OnValidationFailed" Type="@BarcodeType.Code39" Value="@BarcodeValue">
</SfBarcodeGenerator>
public void OnValidationFailed(ValidationFailedEventArgs args)
{
Console.WriteLine(args.Message);
//await toastNotification.ShowCustomToast(new ToastModel { Title = "Error!", Content = "Unsupported input for this barcode type.\n" + args.Message, CssClass = "e-toast-warning", Timeout = 5000 });
}
Hi Aravind,
Yes, the sample you provided is using Blazor Server, but Blazor WASM the OnValidationFailed is triggered infinitely.
Please see the sample I have attached with the similar code but using Blazor WASM.
Also, video of the issue.
Hi Mason,
We deeply regret for inconvenience caused. We have tried to fix the issue, but the fix gets failed on when we tried to update the value for the barcode. Due to complexity of issue , we are still validating the issue with our core team. As of now, we suggest you to use the below code snippet to avoid the onValidationEvent fired repeatedly. We will check with our internal team and update you with more details on February 18th 2022.
public void OnValidationFailed(ValidationFailedEventArgs args) {
if(val == 0) { Console.WriteLine(args.Message); val++; } } void ButtonClicked() { val = 0; } |
Regards
Aravind R