如何阻止 CompositeControl TabIndex 属性在容器跨度上设置 tabindex
我编写了一个继承自 CompositeControl 的自定义服务器控件。 当控件被实例化时,我动态地将一个 TextBox 添加到其 Controls 集合中。 我已重写 TabIndex 属性,以便在设置该属性时,它会将该值应用于子 TextBox 控件的 TabIndex 属性。 问题是,当呈现 CompositeControl 时,它包含一个 span 标记作为整体容器,并且在 span 以及输入 (TextBox) 控件上设置 tabindex 属性。 这使得光标实际上跳到了跨度,这不是我想要的。 关于如何让 CompositeControl 不在跨度上呈现 tabindex 属性有什么想法吗?
I wrote a custom server control that inherits from CompositeControl. When the control is instantiated, I am dynamically adding a TextBox to its Controls collection. I have overridden the TabIndex property so that when it is set, it applies the value to the TabIndex property of the child TextBox control. The problem is that when the CompositeControl is rendered, it includes a span tag as the overall container, and it is setting the tabindex property on the span as well as the input (TextBox) control. This makes the cursor actually tab to the span, which is not what I want. Any ideas on how to get the CompositeControl to not render the tabindex property on the span?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我回答了我自己的问题。 事实证明,包装器 span 标记根本不是必需的,您只需在继承自 CompositeControl 的类中包含以下覆盖即可将其删除:
I answered my own question. It turns out that the wrapper span tag is not really necessary at all, and you can remove it by simply including the following overrides in the class inheriting from CompositeControl: