【发布时间】:2014-09-03 15:25:09
【问题描述】:
我需要在 C# 的循环中动态创建占位符的名称,但我不知道如何获得正确的名称。
占位符在 aspx 页面中设置,currMaxValues 是最大值。占位符集的数量。
我当前的标记:
const int currMaxValues = 6;
for (int i = 0; i < currMaxValues; i ++)
{
//new placeholdernames
string currPlaceholderTime = "placeholderTime" + i;
string currPlaceholderMore = "placeholderZusatz" + i;
string currPlaceholderIco = "placeholderIco" + i;
string currPlaceholderTemp = "placeholderTemp" + i;
//elements for placeholders
Label time = null;
Label more = null;
Image img = null;
Label temp = null;
//built the stuff for the placeholders
DateTime currTime = DateTime.Now;
int hour = currTime.Hour;
time.Text = hour.ToString();
//(PlaceHolder)currPlaceholderTime.Controls.add(time);
}
是否可以使用我在循环开始时创建的占位符的名称来访问控件?
感谢您的帮助!
【问题讨论】:
标签: c# asp.net placeholder