MVC FormCollection 中的复选框和单选按钮

发布于 2024-12-04 18:41:40 字数 298 浏览 3 评论 0原文

我做了一些搜索以确定选择了哪个单选按钮以及是否选中了复选框,或者不只是使用传递给我的 Action 方法的 FormCollection。

由于我不会在这里讨论的原因,我无法使用 Html 助手,因此自动添加隐藏字段对我来说是不可行的。我确实发现有人建议在集合对象上使用 GetValue() 来确定选择哪个单选按钮,但我似乎无法使其工作,因为它正在寻找 ValueProvider 并且我不确定将其放在哪里基本上

我只是想能够确定单击了哪个单选按钮以及是否选中了表单集合的复选框......为什么这么难?

有人能指出我正确的方向吗?

I did some searching for determining which radio button is selected and if checkboxes are checked or not just using the FormCollection that is being passed to my Action method.

For reasons I won't go into here, I can't use Html helpers so the auto adding of hidden fields is out for me. I did find someone that suggested using GetValue() on the collection object to determine which radio button is selected, but I can't seem to make that work as it is looking for a ValueProvider and I"m not sure where to put that in.

Basically I just want to be able to determine which radio button is clicked and if a checkbox is checked or not with a form collection....why is that so hard?

Can anyone point me in the right directon please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

逆光下的微笑 2024-12-11 18:41:40

自从我查看此内容以来已经有一段时间了,但这是否与仅在选中复选框后才提交的复选框有关。

就好像它已提交并已检查一样。

如果您的复选框名称显示为已提交,则遍历表单中的项目。

Been a while since I have looked at this but could it have something to do with check boxes only being submitted if they are checked.

As in if it is submitted its checked.

Iterate through the items in the form if the name of your check box appears its been submitted.

月下伊人醉 2024-12-11 18:41:40

我最终序列化了我的帖子数组,单选按钮和复选框就正常工作了。

I ended up serializing my post array and the radio buttons and checkboxes just worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文