Advertisement
Guest User

Untitled

a guest
Apr 16th, 2012
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. How to save checkbox checked values in Database [closed]
  2. public ActionResult Save(int id, bool status){}
  3.  
  4. @Html.CheckBox("somename", item.Status)
  5. <input name="somename" type="hidden" value="false"/>
  6.  
  7. @using(Html.BeginForm()) {
  8. @Html.Checkbox(...)
  9. }
  10.  
  11. <script type="text/javascript">
  12. $(document).ready(function () {
  13. $('form').ajaxForm({
  14. success: Saved,
  15. error: HandleError
  16. });
  17. });
  18.  
  19. function Error(response, status, err) {
  20. // code to handle error here
  21. }
  22.  
  23. function Saved(responseText, statusText, xhr, $form) {
  24. // code to handle succes, if any
  25. }
  26. </script>
  27.  
  28. public ActionResult Save(int id, bool status){}
  29.  
  30. public class Settings
  31. {
  32. public bool Status { get; set; }
  33. // more properties here
  34. }
  35.  
  36. public ActionResult Save(int id, Settings settings){}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement