ASP.NET MVC 3 Razor视图onclick编码

4
我正在尝试使用以下代码使复选框提交所在的表单:
@Html.CheckBox("Completed", new { onclick = "$(this).parent('form:first').submit();" })
但是它一直将'form:first'中的'渲染为html编码值。有什么解决办法吗?
谢谢
Nick
1个回答

2
为什么不使用jQuery的click事件来连接它?
@Html.CheckBox("Completed", new { id = "myButtonID" })

然后在您的js代码中...
$(function(){

  $("#myButtonID").click(function(){
      //submit the form here
  });

});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接