如何申请元素标签? [英] How to request to element label?
本文介绍了如何申请元素标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!最近3个小时我试图找到关于如何请求标签不是标准方法的信息。
我的意思是下一个结构:
在循环中我有变量i,增加到一个并且有代码行:
Hi! Last 3 hours i tried to find unfo about how to request to label not standart method.
I mean the next construction:
In loop i have variable i, that increment up to one and there is code line:
label_+i.text = "Test";
如何正确写入?
所以,我希望更改文本所有标签名称为label_1,label_2等
How it write correctly?
So, i want change text all label that have names label_1, label_2 etc
推荐答案
通过一些铸造,您可以执行以下操作
With a bit of casting you could do the following
For(int i = 0; i < 20; i++)
{
Control holderControl = Form.FindControl(String.Format("Label_{0}",i));
if(holdControl != null) ((label)holderControl).Text = "My New Text";
}
这篇关于如何申请元素标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文