.NET - 获取表单字段键/值对?

发布于 2024-08-28 07:53:57 字数 428 浏览 4 评论 0原文

我有一个带有文本框的表单,我想在提交表单后对值运行一些服务器端验证代码。我计划获取页面上的所有文本框控件并将它们添加到列表中,然后运行一个 for every 循环,该循环表示列表中的每个控件查询数据库,其中 fieldValidation.Name = Control.Name。这将返回给我一个对象和一个关联的函数,然后我可以在其中输入 Control.Value 并实际执行验证。

我的朋友告诉我构建列表是没有必要的,因为所有语言都有一种从表单获取键/值对的方法(他不了解 .NET,所以无法帮助我)。我可能在这里搜索了错误的术语,但我一直无法找到结果,或者也许我误解了我的朋友。

是否有某种字典或键/值对在提交表单时自动生成,其中包含提交的值以及......我猜还有控件?还是我只是误会他了。如果他只是说根据表单提交填充键/值对,那么在这种情况下,这对包含控件的列表有何帮助?

谢谢=)

I've got a form with textboxes and I want to run some server side validation code on the values after the form is submitted. I was planning to grab all the textbox controls on the page and adding them to a list, then running a for each loop that says for each control in the list query the database where fieldValidation.Name = Control.Name. This would return to me an object and an associated function where i coudl then input the Control.Value and actually perform the validation.

My friend told me building the list is not necessary because all languages have a way to get key/value pairs from forms (he doesn't know .NET so coudln't help me). I may be searching the wrong term here but I have not been able to find a result, or maybe I misunderstood my friend.

Is there some kind of dictionary or key/value pair automatically generated upon form submissions that contains the value that was submitted and...I guess also the control? Or am I just misunderstanding him. If he was just saying populate a key/value pair based on the form submissions, how does that help me in this situation over a list that contains the control?

Thanks =)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文