如何找到动态文本框tabindex [英] how to find the dynamic textbox tabindex
本文介绍了如何找到动态文本框tabindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int cnt = 0;
TextBox tb1 = new TextBox();
tb1.Style["text-align"] = "Right";
tb1.ID = "Tab" + cnt.ToString();
tb1.TabIndex = cnt;
cnt++;
tb1.ID = "txt" + k;
tb1.Text = "0";
推荐答案
看看这个
Have a look on this Link.you will an idea.
尝试一下:
Try this:
int cnt = 0;
TextBox tb1 = new TextBox();
tb1.Style["text-align"] = "Right";
tb1.ID = "Tab" + cnt.ToString();
tb1.TabIndex = cnt;
cnt++;
始终在Page_Init事件中添加控件,因为它不会丢失viewstate.
现在,使用Page.FindControl函数查找控件.试试这个:
Always add your controls in Page_Init event, because it''ll not lose the viewstate.
Now find your controls using Page.FindControl function. Try this:
TextBox tb = (TextBox) Page.FindControl("Tab0");
int tabInedex = tb.TabIndex;
//Now here you found your tab index of the control you added dynamically.
--Amit
--Amit
这篇关于如何找到动态文本框tabindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文