当前位置: 代码迷 >> ASP.NET >> 怎么在页面间传递数组
  详细解决方案

怎么在页面间传递数组

热度:8004   发布时间:2013-02-25 00:00:00.0
如何在页面间传递数组?
可以用Server.Transfer来传递数组吗?Session太费机器资源了,代码如下,我想把aw[]这个数组传递到test2.aspx页面上
C# code
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace Pranser{    public partial class test1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {                    }        protected void TextBox1_TextChanged(object sender, EventArgs e)        {            for (int i = 0; i < int.Parse(TextBox1.Text); i++)            {                TextBox tb = new TextBox();                tb.ID = "tb"+i.ToString();                Update1.ContentTemplateContainer.Controls.Add(tb);            }        }        protected void Button1_Click(object sender, EventArgs e)        {            int xx = 0;            string[] aw = new string[int.Parse(TextBox1.Text)];                        for (int i = 0; i < int.Parse(TextBox1.Text); i++)            {                string dd = Request.Form["ctl00$ContentPlaceHolder1$tb" + i.ToString()].ToString();                xx = xx + int.Parse(dd);                aw[i] = dd;            }            Totol.Text = aw[1].ToString();            Server.Transfer("test2.aspx");        }    }}



------解决方案--------------------------------------------------------
C# code
 int xx = 0; string temp="";            string[] aw = new string[int.Parse(TextBox1.Text)];                        for (int i = 0; i < int.Parse(TextBox1.Text); i++)            {                string dd = Request.Form["ctl00$ContentPlaceHolder1$tb" + i.ToString()].ToString();                xx = xx + int.Parse(dd);                  temp+= dd+",";                aw[i] = dd;            }            Totol.Text = aw[1].ToString();            Response.Redict("test2.aspx?temp="+temp.TrimEnd(',')); //test2页面再split(',')还原            //Server.Transfer("test2.aspx");
  相关解决方案