Barcode Generator Hangs on invalid characters.

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>


16 Replies 1 reply marked as answer

SS Sivakumar Sekar Syncfusion Team November 25, 2021 01:08 PM UTC

Hi Mason 

We have added the sample link and a video link to demonstrate how to use the OnValidationFailed event when entering the invalid characters. Please refer to the below sample link and video link. 



Regards, 
Sivakumar   



MC Mason Channer November 30, 2021 08:42 PM UTC

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.


Attachment: NativeNodeBlazorWASM_de433a1f.zip


SS Sivakumar Sekar Syncfusion Team December 1, 2021 11:52 AM UTC

Hi Mason, 

We are validating your requirements and update you with more details on December 3rd, 2021. 

Regards,  
Sivakumar    




MC Mason Channer replied to Sivakumar Sekar December 14, 2021 03:39 PM UTC

Hi Sivakumar, any update on this?



AR Aravind Ravi Syncfusion Team December 15, 2021 01:43 PM UTC

Hi Mason,    

We deeply regret for the inconvenience caused. 
    
Reported Issue : When enter invalid characters in barcode OnValidationEvent gets triggered continuously 
      
We can reproduce the issue and confirmed this as a defect. We have logged a defect report for this issue. We will fix this issue and provide the patch on January 4th, 2022 weekly patch release.    
   
    
Regards,    
Aravind Ravi 



AR Aravind Ravi Syncfusion Team December 27, 2021 12:28 PM UTC

Hi Mason, 
 
On our further analysis of the issue, issue occurs due to the while we click on the button on the alert box, validation event gets fired continuously. To overcome this, you can use the console Writeline in the onValidationEvent, so that barcode does not get rerendered and the onValidation event does not gets triggered continuously.  Please refer below code snippet 
 
public void OnValidationFailed(ValidationFailedEventArgs args) 
    { 
 
        Console.WriteLine(args.Message); 
 
    } 
 
 
We found that issue is due to while click the button on alert box, the component gets rerendered repeatedly. We suspect this behavior is a Blazor Native and we are checking on this issue. 
 
Regards 
Aravind Ravi 



AR Aravind Ravi Syncfusion Team January 5, 2022 01:42 PM UTC

Hi Mason, 

We have checked the reported issue with the blazor team. They said that delegate event automatically triggers a UI render. i.e. When we click on the ok button on the alert box, the component gets rerendered automatically. So instead of use the alert box, you can use the console.writeline command as we said earlier. For more information, please refer to the below link 


Regards 
Aravind Ravi 



MC Mason Channer January 25, 2022 05:21 PM UTC

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 });
    }





AR Aravind Ravi Syncfusion Team January 27, 2022 07:00 AM UTC

Hi Mason, 

We have created a sample to use SfTextBox to show barcode value. When we tried to use console.WriteLine to show message, the OnValidationFailed event gets triggered only once. We have attached a video demonstration of event gets triggered only once. Please find the video and sample in below link 



If we misunderstood your requirement, please share us a video demonstration of issue or modify the above sample illustrating issue with issue replication steps. This would help us to serve you better. 

Regards 
Aravind Ravi 



MC Mason Channer replied to Aravind Ravi January 27, 2022 06:52 PM UTC

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.


Attachment: BlazorApp1_3c2e473b.zip


AR Aravind Ravi Syncfusion Team January 28, 2022 10:53 AM UTC

Hi Mason, 
We are validating your requirements and update you with more details on February 1st 2022. 
 
Regards 
Aravind Ravi 



AR Aravind Ravi Syncfusion Team February 2, 2022 04:33 PM UTC

Hi Mason, 

We are checking the issue with our internal team and update you with more details on February 4th 2022. 

Regards 
Aravind Ravi 



AR Aravind Ravi Syncfusion Team February 9, 2022 03:58 AM UTC

Hi Mason, 

On our further validation We have found that onvalidationEvent in the blazor server app in the visual studio Version 16.11.9 Preview 1.0 with dotnet 6, the onValidationEvent do not get triggered twice. It gets triggered only once for the invalid text in the blazor server app. In the blazor WASM app only the component gets rerendered. We are checking this issue with our internal team and update you with more details on February 11th 2022. 

Regards 
Aravind Ravi 



AR Aravind Ravi Syncfusion Team February 16, 2022 08:53 AM UTC

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



SS Sivakumar Sekar Syncfusion Team February 18, 2022 02:29 PM UTC

We can reproduce the issue and a defect report has been logged for this. We will fix the issue and provide the patch by 9th March 2022 in the weekly release. 
 



SS Sivakumar Sekar Syncfusion Team March 10, 2022 09:20 AM UTC

We have fixed the reported issue and included it in our patch release (19.4.0.55 patch) which is rolled out successfully. 

Please upgrade to the latest NuGet version to resolve this issue.   


Marked as answer
Loader.
Up arrow icon