SfDialog, DailogButton and DataAnnotationsValidator issue.

I seem to have an Issue with my SfDialog popup on my RazorPage.  

I have a SfDialog @ref="AddEditForm" that handles my EditForm. Inside my SfDialog @ref="AddEditForm" I encased my EditForm inside a ChildContent. 
In the same RazorPage I have another SfDialog @ref="Duplicates". This SfDialog @ref="Duplicates" will open if I have duplicate data submitted.

My issue is everytime I submit using the ENTER KEY the SfDialog @ref="Duplicates" will open even if the data submitted is valid. The weird thing is clicking the submit button does not have this issue. Only by pressing the ENTER KEY this issue will arise.

To solve this problem I decided to do away with the button type="submit" and use a instead a DialogButton and use the OnClick="mySaveMethod".  The issue regarding my SfDialog="Duplicates" was solved. But another problem occured. Since I'm using the DialogButon my DataAnnotationsValidator will not work. The DataAnnotationsValidator will only work if I use ordinary button type="submit".


Any suggestions will be highly appreciated.


Attachment: product_9bf89707.zip

1 Reply 1 reply marked as answer

IS Indrajith Srinivasan Syncfusion Team April 12, 2021 12:23 PM UTC

Hi Oliver, 
 
Greetings from Syncfusion support, 
 
Query: “My issue is everytime I submit using the ENTER KEY the SfDialog @ref="Duplicates" will open even if the data submitted is valid. The weird thing is clicking the submit button does not have this issue. Only by pressing the ENTER KEY this issue will arise.” 
 
We have validated your reported query. We couldn’t make a runnable sample, using the shared code blocks. Based on the shared information, you can prevent the dialog (SfDialog @ref="Duplicates")  from being opened if it is valid in the OnOpen DialogEvent of the dialog. Check the below code blocs for reference. 
 
 
<SfDialog @ref=”@Duplicates” Width="350px" @bind-Visible="@IsVisible" ShowCloseIcon="true" IsModal="true"> 
    <DialogEvents OnOpen="@onOpen"></DialogEvents> 
</SfDialog> 
 
@code { 
     public void onOpen(BeforeOpenEventArgs args) 
    { 
       // Prevent dialog from being opened. 
        args.Cancel = true; 
    } 
} 
 
 
Please let us know if the solution helps, 
 
If the above requirement doesn’t meet your requirements, can you please share us the following details ? 
  • If possible, can you please replicate the issue in a sample and revert back to us ?
  • Can you please, share us the issue reproducing steps. if any, for reproducing the reported issue from our end ?
Regards, 
Indrajith 


Marked as answer
Loader.
Up arrow icon