开发者

keyup or onclick event for checkbox generated server side

开发者 https://www.devze.com 2023-02-11 19:13 出处:网络
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 2nd parameter of true, see b

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 2nd parameter of true, see below:

Response.Write(Html.CheckBox("chkStatus_" + item.Value, true) + " " 
    开发者_运维知识库                                      + item.Text + "<br />");


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号