1.<asp:Literal ID="li" runat="server" />
2.Request.QueryString["id"];
3.后台动态添加服务器控件到前台
第一步:在我们所在的页面动态添加一个容器,例如(div),并标记为服务器类型(runat=“server”)
<div id="div" runat="server"></div>
第二步:动态创建服务器控件
private string k = "1";
protected void btnAdd_Click(object sender, EventArgs e)
{
TextBox txt;
txt = new TextBox();
txt.ID = "txt" + k;
this.div.Controls.Add(txt);
}
第三步:获取添加控件的内容
protected void btnShow_Click(object sender, EventArgs e)
{
//TextBox txt;
// txt = this.div.FindControl("txt"+k) as TextBox;
// this.li.Text = txt.Text;
this.li.Text =Request.Form["txt"+k].ToString();
}
注:动态添加多个服务器控件
int j=0;
int k=0;
TextBox txt;
for (int i = 0; i < DropDownList1.SelectedIndex; i++)
更多资料:http://hi.baidu.com/shaoxiaoming/blog/item/72e579230647df4dad34deb3.html