递归获取所有选中复选框的 ID
我有一个名为 pnlCategories 的 ASP.NET 面板。我想要做的是创建一个函数,该函数返回在此面板中选中的所有复选框的列表通用列表。此函数必须遍历其他子控件(包括其他面板和表格)才能找到所有复选框。有人知道如何做到这一点吗?顺便说一句,这是 C#。
I have an ASP.NET panel called pnlCategories. What I am trying to do is create a function that returns a List generic list of all Check Boxes that are checked inside this panel. There are other child controls (including other panels and tables) that this function will have to traverse through to find all the check boxes. Anyone have any ideas how to do this? This is C# by the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单,也未经测试。这可以适用于仅收集控件 ID,但它的可重用性更高一些,并且非常适合放在公共库中。
及用法:
Simple, also untested. This could be adapted to only collect the controls IDs, but this is a little more reusable and is a great one to have in a common library.
And usage:
我想说这样的东西(改编后)可能会起作用。我还没有测试过这个,但它应该能让你接近某个地方。
I'd say something like this (adapted) might work. I haven't tested this, but it should get you somewhere close.