日期:2014-05-17 浏览次数:21027 次
protected void Button1_Click(object sender, EventArgs e) { string url; url="Default2.aspx?name="+TextBox1.Text + "&pwd="+TextBox2.Text; Response.Redirect(url); }4、新建另一个Web页面,命名为Default2.aspx
protected void Button1_Click(object sender, EventArgs e) { Session["Name"]=TextBox1.Text; Session["Pwd"]=TextBox2.Text; Response.Redirect("Default2.aspx"); }4、新建另一个目标页面命名为Default2 .aspx
protected void Page_Load(object sender, EventArgs e) { Label1.Text=Session["Name"].ToString(); Label2.Text=Session["Pwd"].ToString(); // Session.Remove("Name"); // Session.Remove("Pwd"); }运行后即可看到传递后的结果了。
protected void Button1_Click(object sender, EventArgs e) { Server.Transfer("Default2.aspx"); }4、在Default1.aspx.cs中创建两属性 Name, Pwd来存储TextBox1,TextBox2控件的值,代码如下:
public partial class Default1 : System.Web.UI.Page { public String Name { get { return this.TextBox1.Text; } } public string Pwd { get { return this.TextBox2.Text; } } protected void Page_Load(object sender, EventArgs e) { } protected void Button2_Click(object sender, EventArgs e) { Server.Transfer("Default2.aspx"); } }5、新建另一个目标页面命名为Default2.aspx
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Default1 myver; myver = (Default1)Context.Handler; this.Label1.Text=myver.Name; this.Label2.Text = myver.Pwd; } }
protected void Button1_Click(object sender, EventArgs e) { HttpCookie cookie_name = new HttpCookie("myname"); cookie_name.Value = this.TextBox1.Text; Response.AppendCookie(cookie_name); Server.Transfer("Default2.aspx"); }