Unplanned
Last Updated: 05 Jun 2020 06:38 by ADMIN
Christian
Created on: 05 Jun 2020 06:36
Category: Button
Type: Feature Request
7
Form parameter for the button
I have a EditForm and want to place the submit / reset Buttons outside the EditForm Tag.

In HTML 5 there is a 'form' Attribute on a button Tag, but the Telerik button doesn't seem to have that. I tried using the @attributes parameter, but this didn't work.

So, how can I achieve this?
1 comment
ADMIN
Marin Bratanov
Posted on: 05 Jun 2020 06:38

Hi,

A workaround for the time being could be using a standard button and the Telerik classes to style it:

@using System.ComponentModel.DataAnnotations

<button type="submit" form="myForm" class="k-button k-primary">submit the form from outside</button>

<EditForm id="myForm" Model="@person" OnValidSubmit="@HandleValidSubmit">
    <DataAnnotationsValidator />
    <ValidationSummary />

    <p class="name">
        <label for="nameTextbox">Name:</label>
        <TelerikTextBox @bind-Value="@person.Name" Id="nameTextbox"></TelerikTextBox>
        <ValidationMessage For="@(() => person.Name)"></ValidationMessage>
    </p>

    <p class="height">
        <label for="heightNumeric">Height (cm):</label>
        <TelerikNumericTextBox @bind-Value="@person.Height" Id="heightNumeric" />
        <ValidationMessage For="@(() => person.Height)"></ValidationMessage>
    </p>

</EditForm>

@code {
    // Usually this class would be in a different file
    public class Person
    {
        [Required(ErrorMessage = "Enter a name")]
        [StringLength(10, ErrorMessage = "That name is too long")]
        public string Name { get; set; }

        [Required(ErrorMessage = "Provide your height in centimeters")]
        [Range(1, 300, ErrorMessage = "Nobody is that tall")]
        public int? Height { get; set; }
    }

    Person person { get; set; } = new Person();

    void HandleValidSubmit()
    {
        Console.WriteLine("OnValidSubmit");
    }
}

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.