Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#btnVolunteerSaveBtn').on('click', function() // on click of save button
- {
- if (document.getElementById('RadioNo').checked) { //ID of radio button NO
- var checking = $('#Donation').val(); //ID of textbox from where the value is to be taken if RadioButton No is selected
- if (checking == "") {
- //if nothing is entered, stop from saving in DB
- }
- else
- {
- x = $('#Donation').val(); //ID of textbox from where the value is to be taken if RadioButton No is selected
- $.ajax({
- url: '@Url.Action("DonationValue","VolunteerInfo")',
- data: { name: x },
- type: "POST"
- });
- }
- }
- else
- {
- x = $('#GetNames').val(); //ID of textbox from where the value is to be taken if RadioButton Yes is selected
- $.ajax({
- url: '@Url.Action("DonationValue","VolunteerInfo")',
- data: { name: x },
- type: "POST"
- });
- }
- });
- [HttpPost]
- public ActionResult AddVolunteer(VolunteerInfo viewModel)
- {
- if (!ModelState.IsValid)
- {
- return View("AddVolunteer", viewModel);
- }
- var volunteer = new VolunteerInfo()
- {
- Name = viewModel.Name,
- BirthdayDateTime = viewModel.BirthdayDateTime,
- DonationForWhom = DonationValue() //error here. Expecting a parameter
- };
- _context.VolunteerInfos.Add(volunteer);
- _context.SaveChanges();
- return RedirectToAction("Index", "Home");
- }
- public string DonationValue(string name)
- {
- return name; //Trying to pass this value above
- }
- public string DonationValue(string name = null)
- {
- return name; //Trying to pass this value above
- }
Add Comment
Please, Sign In to add comment