keyup or onclick event for checkbox generated server side

后端 未结 1 1745
小蘑菇
小蘑菇 2021-01-16 00:53

Does anyone know the syntax for setting a click event or keyup event on a checkbox in the following c# code? I\'m trying to set the 3rd parameter htmlAttributes (after the 2

1条回答
  •  醉梦人生
    2021-01-16 01:30

    This should do the trick:

    <%= Html.CheckBox("chkStatus_" + item.Value, true, 
                                      new { onclick = "doSomething();" }); %>
    

    or Razor

    @Html.CheckBox("chkStatus_" + item.Value, true, 
                                      new { onclick = "doSomething();" })
    

    0 讨论(0)
提交回复
热议问题