I working on razor page using .net core 7 . i face issue i can't pass check boxes uncheck to on post function on page model
I have group of checkboxes have checked false with another meaning not checked
so How to get unchecked checkboxes as list of values
my code details
@Html.AntiForgeryToken()
on pagemodel
public async Task OnPost(UserAccessViewModel UserAccessViewModel)
{
}
view model used
public class UserAccessViewModel
{
public int UserId { get; set; }
public UserAccess userAccess { get; set; }
public int[] checks { get; set; }
}
to see expected result i need as below

ahmed salahPosted May 13, 2023, 8:44 PM
my case is static checkbox so can you help me display unchecked checkbox as lsit of 1,2,3
because i can't get checkbox unchecked on post method
Deepak RawatPosted May 13, 2023, 7:15 PM
.cshtmlfile, define a form with checkboxes inside a loop that iterates over a list of items:the corresponding
.cshtml.csfile, handle the form submission in theOnPostmethod:In the code snippet above,
Model.Itemsrepresents the list of items you want to display checkboxes for. The checkbox values are submitted in theselectedItemsarray. By comparing the submitted values with the original list, you can determine which checkboxes were left unchecked. In the example, the unchecked items are processed inside theif (!isSelected)block, but you can modify it according to your needs.ahmed salahPosted May 13, 2023, 7:10 PM
can you please help me answering by post code here please
Deepak RawatPosted May 13, 2023, 6:51 PM
Hi I don't know more about your problem but you can find solution here:
https://www.learnrazorpages.com/razor-pages/forms/checkboxes