Button Type in ASP.NET MVC Button

7 Feb 20231 minute to read

Button is used as normal click able button, submitting form data, resetting the form data to its initial value. According to the usage of button, you can render the button in three types. Using the Type property, you can easily render the button in following types.

List of Button types

Button The button is a click able button
Submit The button is a submit button (submits form-data)
Reset The button is a reset button (resets the form-data to its initial values)

The following steps explains you the details about rendering the Button with above mentioned button types.

  1. In the CSHTML page, configure the Button widget as follows.
  • CSHTML
  • @*Add the code in CSHTML page to configure and initialize the control*@
    
    
    @* Set the different types for button control as follows.*@
    
    <div class="control">
    
            @Html.EJ().Button("button_button").Text("button").ShowRoundedCorner(true).Size(ButtonSize.Mini).Type(ButtonType.Button)
    
            <br />
    
            <br />
    
            @Html.EJ().Button("button_submit").Text("submit").ShowRoundedCorner(true).Size(ButtonSize.Mini).Type(ButtonType.Submit)
    
            <br />
    
            <br />
    
            @Html.EJ().Button("button_reset").Text("reset").ShowRoundedCorner(true).Size(ButtonSize.Mini).Type(ButtonType.Reset)
    </div>

    Execute the above code to render the following output.

    Button Type in ASP.NET MVC Button

    Different button types