如何查找重复控件 ID 的位置 (C#)
我正在创建大量的动态控件,对于必须分配 ID 的所有内容,我使用有保证的唯一变量来分配它(除非 64 位仅从控件中溢出)。
现在,我有一个问题。我在某处有一个重复的控件,并且我无法发现它添加到哪里或其他任何内容,因为它直到 Page_Load 之后才会发生,这意味着,当抛出异常时,它超出了我自己的代码(我认为像渲染或其他一些内部函数)。
控件名称是“ctlXXX”,其中 XXX 是一个数字(目前始终为 244),此控件 ID 不是我创建的。它是由 ASP.Net 自动生成的(因为我的 ID 都没有以 ctl 为前缀)。那么我该如何纠正这个我看不到的错误呢?谁能建议找到我的错误的方法(我真的希望这不是 ASP.Net 中的错误)?
另外,我最近通过使用复制函数得到了错误,该函数将在自定义控件上执行成员方式复制,然后它将重置所有控件以具有唯一 ID 或为空,因为这部分发生在控件加载到之前自定义控件,它是面板的后代)
任何人都可以给我关于如何找到这个错误的建议吗?
I am creating huge amounts of dynamic controls, and for everything that must have an ID assigned, I assign it using a guaranteed unique variable(unless 64bits overflows from just controls).
Now, I have a problem though. I have a duplicate control somewhere and I can not discover where it is added or anything because it doesn't happen until after Page_Load, which means, it is out of my own code when an exception is thrown(I think at like Render or some other internal function).
The control name is "ctlXXX" where XXX is a number(right now, always 244) this control ID is not being made by me. It is being made by ASP.Net automatically(as none of my IDs are prefixed with ctl). So how do I correct this error that I can not see? Can anyone suggest ways of finding my error(I really hope this isn't a bug in ASP.Net)?
Also, I got the error just recently by using a Copy function which will do a Memberwise copy on a custom control, and then it will reset any controls to have either a unique ID or to be null as this part happens before controls are loaded into the custom control, which is a descendant of Panel)
Can anyone give me advice on how to find this bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你想看看 INamingContainer 界面。我认为它会解决你的问题,但你必须派生一个新的控制类才能做到这一点。
I think you want to look at the INamingContainer interface. I think it will solve your problem but you will have to derive a new control class to do it.