Guest User

Untitled

a guest
Jul 21st, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. $('#btnVolunteerSaveBtn').on('click', function() // on click of save button
  2.  
  3. {
  4. if (document.getElementById('RadioNo').checked) { //ID of radio button NO
  5. var checking = $('#Donation').val(); //ID of textbox from where the value is to be taken if RadioButton No is selected
  6. if (checking == "") {
  7. //if nothing is entered, stop from saving in DB
  8. }
  9. else
  10. {
  11. x = $('#Donation').val(); //ID of textbox from where the value is to be taken if RadioButton No is selected
  12. $.ajax({
  13. url: '@Url.Action("DonationValue","VolunteerInfo")',
  14. data: { name: x },
  15. type: "POST"
  16. });
  17. }
  18. }
  19. else
  20. {
  21. x = $('#GetNames').val(); //ID of textbox from where the value is to be taken if RadioButton Yes is selected
  22. $.ajax({
  23. url: '@Url.Action("DonationValue","VolunteerInfo")',
  24. data: { name: x },
  25. type: "POST"
  26. });
  27. }
  28.  
  29. });
  30.  
  31. [HttpPost]
  32. public ActionResult AddVolunteer(VolunteerInfo viewModel)
  33. {
  34. if (!ModelState.IsValid)
  35. {
  36. return View("AddVolunteer", viewModel);
  37. }
  38. var volunteer = new VolunteerInfo()
  39. {
  40. Name = viewModel.Name,
  41. BirthdayDateTime = viewModel.BirthdayDateTime,
  42. DonationForWhom = DonationValue() //error here. Expecting a parameter
  43. };
  44.  
  45. _context.VolunteerInfos.Add(volunteer);
  46. _context.SaveChanges();
  47. return RedirectToAction("Index", "Home");
  48.  
  49. }
  50.  
  51. public string DonationValue(string name)
  52. {
  53. return name; //Trying to pass this value above
  54. }
  55.  
  56. public string DonationValue(string name = null)
  57. {
  58. return name; //Trying to pass this value above
  59. }
Add Comment
Please, Sign In to add comment