I made a view with records and each one has accepted and rejected button. On reject, there is a pop-up a modal for writing why. the issue here is whenever I click reject button for any record, it takes the id and status of the first record and the type="button".
I tried changing the type of the reject button type="submit", it works but it goes directly to the controller without showing the popup. literally, I'm going crazy .what am I doing wrong?
my workflow is I'm doing two begin forms one for each button.
Error I am receiving:
the reject button in any records just updates the first one only by taking its Id, status and its stored comment.
The markup is invalid and the selectors are not specific enough. Learn how to use the browser's dev tools when debugging JavaScript as the problem with the code will be very obvious and you will not waste time guessing.
Since all the Modals' id are the same (id= "exampleModal"), and you use id selector here, so the reject button always open the first modal. One solution is to set a unique id for each Modal like below:
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
8 Points
74 Posts
Reject button always updates just the first record
Feb 06, 2020 10:46 AM|khloud_ali39|LINK
Summary of the problem I am having:
I made a view with records and each one has accepted and rejected button. On reject, there is a pop-up a modal for writing why. the issue here is whenever I click reject button for any record, it takes the id and status of the first record and the
type="button"
. I tried changing the type of the reject button type="submit", it works but it goes directly to the controller without showing the popup. literally, I'm going crazy .what am I doing wrong?my workflow is I'm doing two begin forms one for each button.
Error I am receiving:
the reject button in any records just updates the first one only by taking its Id, status and its stored comment.
My code:
the view:
the controller :
I appreciate your help.
All-Star
53051 Points
23634 Posts
Re: Reject button always updates just the first record
Feb 06, 2020 12:52 PM|mgebhard|LINK
The markup is invalid and the selectors are not specific enough. Learn how to use the browser's dev tools when debugging JavaScript as the problem with the code will be very obvious and you will not waste time guessing.
Participant
1320 Points
491 Posts
Re: Reject button always updates just the first record
Feb 07, 2020 09:26 AM|jiadongm|LINK
Hi khloud_ali39,
Since all the Modals' id are the same (id= "exampleModal"), and you use id selector here, so the reject button always open the first modal. One solution is to set a unique id for each Modal like below:
The Action should use the same name parameter to receive the value:
[CustomAuthorize(Roles = AccessRoleHelper.Training_Action)] [HttpPost] public ActionResult Add_Fulfillment_Reject(int Request_ID, bool Status , string Note) { var selectedRequest = db.TBL_Request.Find(theId); selectedRequest.Note = Note; selectedRequest.IsApproved = Status; db.SaveChanges(); TempData["success"] = "Done"; return RedirectToAction("Training_Action"); }
Best Regards,
Jiadong Meng