Forum Discussion
MarioF2110
Sep 20, 2024Copper Contributor
Checkbox values empty if other form fields are empty when POST form
I have hit a road block on a ASP.NET/Razor Pages project I am working on. I have a form with checkboxes. I have a List<int> field that is bound to the Id of the checkboxes. If I submit the form with only the checkboxes checked the List is always null. However, if I type text in a textbox in the form before submitting, the checkbox values are POST'd correctly.
Looking for any hints on things to try or check to to help me narrow down the problem. Thank for any suggestions.
- I wanted a nicer looking confirmation window, but I am not sure how to solve the problem. I am going with, "var proceed = window.confirm("You sure")" instead of displaying a Modal. This returns the appropriate bool value form my OnSubmit function until I can learn another away.
2 Replies
- MarioF2110Copper ContributorThe form does have an "return CheckForm()", OnSubmit event defined. It displays a Modal window if the form's textboxes and dropdowns have a certain value. If I remove the OnSubmit function the form checkboxes POSTs correctly. So, if the CheckFrom() function returns true, things work. It's when I display the Modal and return false that I have a problem.
The Modal does use a Form too, if you click "Continue". So now I realize I am calling a Form POST right after the other. Ultimately, my intent is to confirm the user wants to continue with the original/first form's values and do the query the user defined. I would like to keep the code native to ASP.Net Core/Razor Pages if possible, and not use javascript or jquery.- MarioF2110Copper ContributorI wanted a nicer looking confirmation window, but I am not sure how to solve the problem. I am going with, "var proceed = window.confirm("You sure")" instead of displaying a Modal. This returns the appropriate bool value form my OnSubmit function until I can learn another away.