Can anyone help how to use event from Html.Kendo()

2019-08-09 10:51发布

问题:

I am new to Kendo. Iam using Html.Kendo().CheckBoxFor(m => m.Enable) in MVC cshtml. Unable to add event change for this checkbox. I used Html.Kendo().DropDownListFor which has .Events(e => e.Change("PopulateCountry")) But I dont see same type of event in CheckBox. can anyone help on this

回答1:

The Html.Kendo().CheckBoxFor helper renders a regular html5 checkbox. It is not actually a kendo widget like Html.Kendo().DropDownListFor creates. I believe this is why the helper for CheckBox is lacking an .Events option.

Regardless, you can use the .HtmlAttributes option to add a change handler to the checkbox element instead:

.HtmlAttributes(new { onchange = "PopulateCountry();" })