您的位置:首页 > 编程语言 > ASP

ASP.NET中页面传递参数。

2004-12-14 15:56 316 查看
第一页面用Server.Transfer跳转至第二页面。
第二页面中核心代码如下:
if(!Page.IsPostBack)
{
Webtest1 _webtest1;
_webtest1 = (Webtest1) Context.Handler;
if(_webtest1!=null)
{
ViewState["TNum"] = System.Convert.ToInt32(((TextBox)_webtest1.FindControl("TextBox1")).Text.Trim());
}
}
table1.Controls.Clear();
if(System.Convert.ToInt32(ViewState["TNum"].ToString())>0)
{
for(int i=0;i<System.Convert.ToInt32(ViewState["TNum"].ToString());i++)
{
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell cell = new HtmlTableCell();
TextBox newbox = new TextBox();
newbox.Text = "第"+i.ToString()+"个";
newbox.Width = 180;
newbox.ID = "DynTextBox"+i.ToString();
newbox.Attributes.Add("name", newbox.ID);
//ViewState[newbox.ID] = newbox;
cell.Controls.Add(newbox);
tr.Controls.Add(cell);
table1.Controls.Add(tr);
}
}
//获取动态生成控件中的内容。
string res ="";
for (int i=0;i<System.Convert.ToInt32(ViewState["TNum"].ToString());i++)
{
//res = this.Controls[i].ID;
//Control myControl1 = FindControl("DynTextBox"+i.ToString());
TextBox txt0 = (TextBox)this.FindControl("DynTextBox"+i.ToString());
res+= txt0.Text;
}
Response.Write(res);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: