Programmatic form submission RadzenTemplateForm #1683

Closed
opened 2026-01-29 17:57:14 +00:00 by claunia · 1 comment
Owner

Originally created by @JvanderStad on GitHub (Mar 23, 2025).

Hello 🙋🏻‍♂️

II want to programmatically submit a RadzenTemplateForm from outside the Component by using @ref.

Currently the OnSubmit is protected

https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenTemplateForm.cs#L178

protected async Task OnSubmit()
{
...
}

I can make a PR for this. We can make the method public or we can create a new method that calls the OnSubmit method.

My intended usage:

<RadzenTemplateForm @ref="_refRadzenTemplateForm" />
private RadzenTemplateForm<Type>? _refRadzenTemplateForm { get; set; }

private async Task SubmitFormAsync()
{
	if (_refRadzenTemplateForm == null)
		return;

	await _refRadzenTemplateForm.OnSubmit();
}

What would be the preferred way to expose this?

Thanks

Originally created by @JvanderStad on GitHub (Mar 23, 2025). Hello 🙋🏻‍♂️ II want to programmatically submit a `RadzenTemplateForm` from outside the Component by using **@ref**. Currently the `OnSubmit` is `protected` https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenTemplateForm.cs#L178 ```c# protected async Task OnSubmit() { ... } ``` I can make a `PR` for this. We can make the method `public` or we can create a new method that calls the `OnSubmit` method. My intended usage: ```html <RadzenTemplateForm @ref="_refRadzenTemplateForm" /> ``` ```c# private RadzenTemplateForm<Type>? _refRadzenTemplateForm { get; set; } private async Task SubmitFormAsync() { if (_refRadzenTemplateForm == null) return; await _refRadzenTemplateForm.OnSubmit(); } ``` What would be the preferred way to expose this? Thanks
Author
Owner

@enchev commented on GitHub (Mar 24, 2025):

OnSubmit is a callback raised on onsubmit event of the form. There are various ways to submit the form programmatically, for example using JavaScript: await JSRuntime.InvokeVoidAsync("eval", $@"document.forms[0].submit()"); . Use our forum in the future for such posts.

@enchev commented on GitHub (Mar 24, 2025): OnSubmit is a callback raised on onsubmit event of the form. There are various ways to submit the form programmatically, for example using JavaScript: `await JSRuntime.InvokeVoidAsync("eval", $@"document.forms[0].submit()");` . Use our forum in the future for such posts.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1683