using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace ApplyPanel
{
	/// <summary>
	/// WebForm1 的摘要说明。
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DropDownList DropDown1;
		protected System.Web.UI.WebControls.DropDownList DropDown2;
		protected System.Web.UI.WebControls.CheckBox Check1;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Panel Panel1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN：该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{     
			if (Check1.Checked) 
			{
				Panel1.Visible=false;
			}
			else 
			{
				Panel1.Visible=true;
			}           
			int numlabels = Int32.Parse(DropDown1.SelectedItem.Value);             
			for (int i=1; i<=numlabels; i++) 
			{
				Label lbl = new Label();
				lbl.Text = "Label" + (i).ToString();
				lbl.ID = "Label" + (i).ToString();
				Panel1.Controls.Add(lbl);
				Panel1.Controls.Add(new LiteralControl("<br>"));
			}
			int numtexts = Int32.Parse(DropDown2.SelectedItem.Value);             
			for (int i=1; i<=numtexts; i++) 
			{
				TextBox txt = new TextBox();
				txt.Text = "TextBox" + (i).ToString();
				txt.ID = "TextBox" + (i).ToString();
				Panel1.Controls.Add(txt);
				Panel1.Controls.Add(new LiteralControl("<br>"));
			}
		}
	}
}
