Panel--容器
protected void Button1_Click(object sender, EventArgs e)
{
int a = int.Parse(DropDownList1.SelectedValue);
for (int i = 1; i <= a; i++)
{
Label lb = new Label();
lb.ID = "lbl" + i;
lb.Text = "Label" + i.ToString()+"<br>";
Panel1.Controls.Add(lb);
}
int b = int.Parse(DropDownList2.SelectedValue);
for (int i = 1; i <= a; i++)
{
TextBox tb = new TextBox();
tb.ID = "textbox" + i;
tb.Text = "textbox" + i.ToString();
Literal ll = new Literal();
ll.Text="<br>";
Panel1.Controls.Add(tb);
Panel1.Controls.Add(ll);
}
Literal tt=new Literal();
tt.Text=TextBox1.Text;
Panel1.Controls.Add(tt);
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked)
{
CheckBox1.Text = "显示Panel";
Panel1.Visible = false;
}
else
{
CheckBox1.Text = "隐藏Panel";
Panel1.Visible = true;
}
}
{
int a = int.Parse(DropDownList1.SelectedValue);
for (int i = 1; i <= a; i++)
{
Label lb = new Label();
lb.ID = "lbl" + i;
lb.Text = "Label" + i.ToString()+"<br>";
Panel1.Controls.Add(lb);
}
int b = int.Parse(DropDownList2.SelectedValue);
for (int i = 1; i <= a; i++)
{
TextBox tb = new TextBox();
tb.ID = "textbox" + i;
tb.Text = "textbox" + i.ToString();
Literal ll = new Literal();
ll.Text="<br>";
Panel1.Controls.Add(tb);
Panel1.Controls.Add(ll);
}
Literal tt=new Literal();
tt.Text=TextBox1.Text;
Panel1.Controls.Add(tt);
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked)
{
CheckBox1.Text = "显示Panel";
Panel1.Visible = false;
}
else
{
CheckBox1.Text = "隐藏Panel";
Panel1.Visible = true;
}
}