Dialog OnValidSubmit problem

Hi,

In the file below, by clicking on the delete button, the AcceptDialog method is called and the dialog is closed. I don't want the AcceptDialog method to be called after the delete button is clicked

version: 25.1.35


Attachment: Index_67f13712.zip


1 Reply

KP Kokila Poovendran Syncfusion Team April 2, 2024 09:47 AM UTC

Hi Sarah,


Thank you for reaching out to Syncfusion support!


We have reviewed your requirement regarding preventing the AcceptDialog method from being called when the delete button is clicked in the SfDialog component. To achieve this, we have updated the delete button to specify the type attribute as "button" to ensure that it does not submit the form and trigger the AcceptDialog method.


Here is the updated code snippet:


 <Content>

     <EditForm Model="objData" OnValidSubmit="AcceptDialog">

         <DataAnnotationsValidator />

         @foreach (var item in objData.lstData)

         {

             <div class="d-flex flex-row">

                 <InputText class="form-control" @bind-Value="item.Name" />

                 <button @onclick="()=>DeleteItem(item.Id)" type="button">delete</button>

             </div>

         }

     </EditForm>

 </Content>




By setting the type attribute of the delete button to "button", the AcceptDialog method will not be invoked when the button is clicked, thus addressing your requirement.


We have also provided a sample for your reference, which you can access through the following link: https://blazorplayground.syncfusion.com/rNhftpDrUINeMlUi





If you have any further questions or concerns, please feel free to reach out. We're here to assist you.


Loader.
Up arrow icon