
在使用web site做测试时,动态添加控件时分配一个ID号,在服务器 端按ID号就可以用Request.Form[ID]来获取,可是在web application里却怎么也不行了,原因是自动加了一个ClientID,ID号就变了,我不知道怎样使用我给加的那个,找了好些资料,也是没有结果,没办法,只有用Request.Form集合来取值了,代码如下:
BinGuan b = new BinGuan();
b.ListInfo(userid);
DateTime dt = new DateTime();
for (int i = 0; i < 12; i++)
{
string str = "";
if (i > 0) str = "<br>";
TimeSpan t1 = new TimeSpan(i, 0, 0, 0);
dt = DateTime.Now + t1;
Label l = new Label();
l.Text = str + dt.ToShortDateString() + " ";
p1.Controls.Add(l);
TextBox txt = new TextBox();
string cid = "txt";
if (i < 10)
{
cid += "0" + i.ToString();
}
else
{
cid += i.ToString();