Search results

Name and Value in form submit

The name attribute of the CheckBox is used to group Checkboxes. When the Checkboxes are grouped in form, the checked items value attribute will post to the server on form submit that can be retrieved through the name. The disabled and unchecked CheckBox value will not be sent to the server on form submit.

In the following code snippet, Cricket and Hockey are in the checked state, Tennis is in disabled state and Basketball is in unchecked state. Now, the value that is in checked state only be sent on form submit.

tagHelper
form.cs
<form>
    <ul>
        <li>
            <ejs-checkbox id="cbox2" name="Sport" value="Cricket" label="Cricket" checked="true"></ejs-checkbox>
        </li>
        <li>
            <ejs-checkbox id="cbox3" name="Sport" value="Hockey" label="Hockey" checked="true"></ejs-checkbox>
        </li>
        <li>
            <ejs-checkbox id="cbox4" name="Sport" value="Tennis" label="Tennis"></ejs-checkbox>
        </li>
        <li>
            <ejs-checkbox id="cbox1" name="Sport" value="Basketball" label="Basketball"></ejs-checkbox>
        </li>
        <li>
            <ejs-button id="primarybtn" content="Submit" isPrimary="true"></ejs-button>
        </li>
    </ul>
</form>
<style>
    .e-checkbox-wrapper {
        margin-top: 18px;
    }

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

    li {
        list-style: none;
    }
</style>
public ActionResult Form()
{
    return View();
}