简体   繁体   English

Tab索引不适用于asp.net中的动态添加的控件

[英]Tab index is not working for dynamically added controls in asp.net

I have a web page where there is a requirement to repeat the controls in repeater. 我有一个网页,要求在转发器中重复控件。 Tab indices are already assigned to the control. 选项卡索引已分配给控件。 while repeating those controls by clicking plus button in repeater, they are taking same tab indices as corresponding to previous controls. 通过单击中继器中的加号按钮来重复这些控件时,它们将采用与以前的控件相同的选项卡索引。

eg Tab index for CardHolderFirstName text box in first user control exactly matches with that of CardHolderFirstName text box in second user control. 例如,第一个用户控件中的CardHolderFirstName文本框的选项卡索引与第二个用户控件中的CardHolderFirstName文本框的索引完全匹配。 So when I press tab when focus is set to CardHolderFirstName text box in first user control, instead of setting focus to CardHolderMiddleName text box in first user control; 因此,当在第一个用户控件中将焦点设置为CardHolderFirstName文本框时,当我按Tab时,而不是在第一个用户控件中将焦点设置为CardHolderMiddleName文本框; it sets focus to CardHolderFirstName text box in second user control. 它将焦点设置为第二个用户控件中的CardHolderFirstName文本框。

Can anyone help? 有人可以帮忙吗?

If you add a new control dynamically and want to control it with Tab, be sure to set the tabindex and tabstop property 如果您动态添加新控件并希望使用Tab进行控制,请确保设置tabindex和tabstop属性

Button button1 = new Button();
button1.TabIndex = 1;
button1.TabStop = true;

See MSDN 参见MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM