How to get checkbox have checked false or not checked on post method on mvc razor page?

huangapple go评论73阅读模式
英文:

How to get checkbox have checked false or not checked on post method on mvc razor page?

问题

I work on mvc razor page I face issue I can't get checkbox not checked or have checked false on post method on page model csharp.
只在C#页面模型的POST方法中获取未选中或已选中为false的复选框。

Only I can get selected checkbox true.
我只能获取选中的复选框为true。



























































How to get checkbox have checked false or not checked on post method on mvc razor page?

Expected Result Return not checked checkboxes on list

so if i have multi check box not check so return it on list this exactly what I need

Updated post

to summarize what i need

suppose i have 5 checkbox

3 checkboxes is checked true

2 checkboxes is checked false

code above posted return only 3 checked

but 2 checkbox is checked false not returned

I need to get list of checkboxes not checked so 2 checkbox not checked not retuned on list

答案1

得分: 1

这似乎是关于不使用ASP.NET MVC,而是使用ASP.NET Razor Pages的问题。如果是这样,请查看此指南以了解如何绑定复选框:

https://www.learnrazorpages.com/razor-pages/forms/checkboxes

英文:

It seems you are not using ASP.NET MVC, but ASP.NET Razor Pages. If so, check this guide for binding checkboxes:

https://www.learnrazorpages.com/razor-pages/forms/checkboxes

huangapple
  • 本文由 发表于 2023年5月13日 20:35:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76242758.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定