/// <summary>
        /// Handles the submit event of the form.
        /// </summary>
        protected async Task OnSubmit()
        {
            if (EditContext != null)
            {
                bool valid = EditContext.Validate();

                if (valid)
                {
                    await Submit.InvokeAsync(Data);

                    if (Action != null)
                    {
                        await JSRuntime.InvokeVoidAsync($"Radzen.submit", Element);
                    }
                }
                else
                {
                    await InvalidSubmit.InvokeAsync(new FormInvalidSubmitEventArgs()
                    {
                        Errors = EditContext.GetValidationMessages()
                    });
                }
            }
            else
            {
                if (Action != null)
                {
                    await JSRuntime.InvokeVoidAsync($"Radzen.submit", Element);
                }
            }
        }
Example #2
0
        protected async Task OnSubmit()
        {
            if (EditContext != null)
            {
                bool valid = false;

                try
                {
                    valid = EditContext.Validate();
                }
                catch
                {
                }

                if (valid)
                {
                    await Submit.InvokeAsync(Data);
                }
                else
                {
                    await InvalidSubmit.InvokeAsync(new FormInvalidSubmitEventArgs()
                    {
                        Errors = EditContext.GetValidationMessages()
                    });
                }
            }
        }