// Generate the Label controls.
int numlabels = Int32.Parse(DropDown1.SelectedItem.Value);
int numtexts = Int32.Parse(DropDown2.SelectedItem.Value);
for (int i = 1; i <= numlabels; i++)
{
Label l = new Label();
l.Text = "intebank" + (i).ToString();
l.ID = "intebank" + (i).ToString();
Response.Write("用户密码" + i + ":" + l.Text + "<br>");
Panel1.Controls.Add(l);
Panel1.Controls.Add(new LiteralControl("<br>"));
// Generate the Textbox controls.
}
for (int j = 1; j <= numtexts; j++)
{
TextBox t = new TextBox();
t.Text = "1800" + (j).ToString();
t.ID = "1800" + (j).ToString();
Response.Write("登陆账号" + j + ":" + t.Text + "<br>");
Panel1.Controls.Add(t);
Panel1.Controls.Add(new LiteralControl("<br>"));
}这是在Panel里面 用二个For 循环 生成 Label 和Textbox :
问题 : 怎么获得那些生成的Label 和Textbox的值
int numlabels = Int32.Parse(DropDown1.SelectedItem.Value);
int numtexts = Int32.Parse(DropDown2.SelectedItem.Value);
for (int i = 1; i <= numlabels; i++)
{
Label l = new Label();
l.Text = "intebank" + (i).ToString();
l.ID = "intebank" + (i).ToString();
Response.Write("用户密码" + i + ":" + l.Text + "<br>");
Panel1.Controls.Add(l);
Panel1.Controls.Add(new LiteralControl("<br>"));
// Generate the Textbox controls.
}
for (int j = 1; j <= numtexts; j++)
{
TextBox t = new TextBox();
t.Text = "1800" + (j).ToString();
t.ID = "1800" + (j).ToString();
Response.Write("登陆账号" + j + ":" + t.Text + "<br>");
Panel1.Controls.Add(t);
Panel1.Controls.Add(new LiteralControl("<br>"));
}这是在Panel里面 用二个For 循环 生成 Label 和Textbox :
问题 : 怎么获得那些生成的Label 和Textbox的值
{
if (c is Label)
{
string sText = ((Label)c).Text;
}
else if (c is TextBox)
{
string sText = ((TextBox)c).Text;
}
}
用 request.form[""]得到值