Submit name and value in form

26 Oct 20222 minutes to read

The name attribute of the Switch is used to group Switches. When the Switches are grouped in form, the checked items value attribute will post to the server on form submit. The disabled and unchecked Switch values will not be sent to the server on form submit.

In the following code snippet, USB and Wi-Fi in the checked state, and Bluetooth is in disabled state. Values that are in checked state only be sent on form submit.

<div id='container'>
<form>
    <table class='size'>
        <tr>
            <td class='lSize'>USB</td>
            <td>
                <ejs-switch id="switch1" checked="true"></ejs-switch>
            </td>
        </tr>
        <tr>
            <td class='lSize'>Wi-Fi</td>
            <td>
                <ejs-switch id="switch2" checked="true"></ejs-switch>
            </td>
        </tr>
        <tr>
            <td class='lSize'>Bluetooth</td>
            <td>
                <ejs-switch id="switch3" disabled="true"></ejs-switch>
            </td>
        </tr>
        <tr>
            <td>
                <ejs-button id="btnElement" ></ejs-button>
            </td>
        </tr>
    </table>
</form>
</div>

<style>

button {
  margin: 20px 0 0 5px;
}

.size tr td {
  padding: 10px;
}

.size .lSize {
  font-family: "Roboto", "Segoe UI", "GeezaPro", "DejaVu Serif", "sans-serif";
  font-size: 13px;
}

.size .lSize label {
  user-select: none;
} 
</style>
public ActionResult Default()
    {
            return View();
    }