0

Is there any way to pass the checkbox values to the controller on checking from a list of checkbox without using any submit button or any jquery Ajax? I just want to use only asp.net mvc property.

1
  • We are not clear about what you want or what you are trying. Post relevant code as well to get better understanding. Commented Sep 10, 2014 at 11:08

2 Answers 2

1

As user1576559 sad in comment:

I want to submit the form when I'll check or uncheck any of the checkboxs without using any jquery or ajax

Here it is:

@using (Html.BeginForm("Update", "Home"))
{
    <p>Checkboxes:</p>
    @Html.CheckBox("chk1", new { onchange = "this.form.submit()" }); <br/>
    @Html.CheckBox("chk2", new { onchange = "this.form.submit()" }); <br />
    @Html.CheckBox("chk3", new { onchange = "this.form.submit()" }); <br />
}
Sign up to request clarification or add additional context in comments.

Comments

0

As per my understanding, you need to use @Html.CheckboxFor(m=>m.PropertyName) when you send the page to server then you get the updated checkbox status.

3 Comments

Yes..I know that.But it's only possible when I submit the form by clicking submit button.But my requirement is little a bit different.I want to submit the form when I'll check or uncheck any of the checkboxs without using any jquery or ajax.
@user1576559 without sending any request how the controller know that you have changed the check box status
Do you just want to submit the form automatically when the checkbox changes? In which case you can just use an event handler e.g.: $("#yourCheckboxID").click(function(){$('#yourFormID').submit();}); or the JavaScript equivalent. You can't do this without JavaScript, but it will submit the form normally, not as an Ajax call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.