Sunny
Sunny

Reputation: 3295

How to fire oncheckedchanged event for @Html.CheckBoxFor in MVC 4

How can I fire the oncheckedchanged event with the following code?

View:

@Html.CheckBoxFor(m => m.Baseline, new { @class = "formCheckbox", tabindex = "24"})

Model:

public bool Baseline { get; set; }

Upvotes: 0

Views: 2033

Answers (1)

levelnis
levelnis

Reputation: 7705

The oncheckedchanged event is a webforms event rather than MVC. If you want to capture the change event, you can do that using javascript. Here's an example using jquery:

(function($) {
    $('#Baseline').on("change", function(e) {
        // do stuff relating to change event here
    });
})(jQuery);

Upvotes: 1

Related Questions