ASP.NET MVC 3 Razor displays onclick encoding

I am trying to get my checkbox to submit the form it is in using the code below:

@ Html.CheckBox ("Finished", new {onclick = "$ (this) .parent ('form: first'). Submit ();"})

It saves the rendering of the "around" form: first, "how html encodes the values." Any ideas how to fix this?

thanks

Nick

+4
source share
1 answer

why not just hook it into a jquery click event

@Html.CheckBox("Completed", new { id = "myButtonID" }) 

then in your js code ...

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

All Articles