Hi there,
I am looking for some guidance when using Syncfusion controls. I have a form in a Dialog which renders okay, and I am using DialogTemplates. My question concerns the varying behaviors for the form, how to setup the buttons, etc.
For example, when using DialogTemplates Syncfusion makes the Enter key the default for form submissions. Accordingly, if the form is valid the Blazor OnValidSubmit event is triggered. However, it is unclear how to setup the "Submit" *button* for consistent behavior because that takes an OnClick event, which I suppose I can wire up to the same method that OnValidSubmit calls. I need consistent form validation and for the EnterKey and Submit button to work consistently.
What is the difference or pros/cons of using DialogButton by itself, vs. using DialogButton with an DialogButtonModel.
For example:
<DialogButton Content="Submit" IsPrimary="true" OnClick="@OnClickSubmit" />
vs.
<DialogButton OnClick="@DlgConfirm" Type="Submit">
<DialogButtonModel Content="Confirm" IsPrimary="true" Disabled="true"></DialogButtonModel>
</DialogButton>
Then, in the source for your Blazor Demos (Dialog Template) you are using a regular HTML submit button...
Can you provide some clarity on these questions and the best practice here?
Thank you in advance!
-Jp
Hi Vinitha
I want to submit a validated form with the DialogButton but it keeps failing.
I have an EditForm populated in a SfDialog tag and I have buttons in the DialogButtons tags. When I click the submit button, it calls the bind method and submits the form without validating it. How do I trigger a form's OnValidSubmit method from the DialogButton
Hi John,
To resolve your issue, you can add an ID to the EditForm and assign it to the form attribute on the submit button. I've attached a sample and the following code for your reference.
<SfDialog > <DialogTemplates> <Content> <EditForm id="@MyID" OnValidSubmit="@SaveAuthor1"></EditForm> </Content> </DialogTemplates> <DialogButtons> <DialogButton form="@MyID" Type=ButtonType.Submit IsPrimary="true" Content="Save" OnClick="@OnBtnClick1" /> </DialogButtons> </SfDialog> @code{ private string MyID = "myid"; } |
Please let us know if you have any other concerns.