using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class tmp : System.Web.UI.Page
{
protected void
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "behind";
// 创建一个DropDownList
DropDownList d = new DropDownList();
// TrackViewState()方法将被触发去跟踪这个DropDownList的状态,所以其状态将被保持
PlaceHolder1.Controls.Add(d);
if (!IsPostBack)
{
d.Items.Add("test1");
d.Items.Add("test2");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected override void OnInit(EventArgs e)
{
string str=null;
// 通过Post数据得到用户在TextBox里输入的值
if (Request.Form["TextBox1"] != null)
str = Request.Form["TextBox1"].ToString();
Label lb = new Label();
lb.Text = "您的姓名是:"+str;
PlaceHolder1.Controls.Add(lb);
// 动态生成控件的代码
base.OnInit(e);
}
}