62,268
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
// Value sent using HttpResponse
Response.Redirect("receive .aspx?Name=" + txtName.Text);
}
protected void Button2_Click(object sender, EventArgs e)
{
HttpCookie cName = new HttpCookie("Name");
cName.Value = txtName.Text;
Response.Cookies.Add(cName);
Response.Redirect("receive .aspx");
}
protected void Button3_Click(object sender, EventArgs e)
{
Session["Name"] = txtName.Text;
Response.Redirect("receive .aspx");
}
protected void Button4_Click(object sender, EventArgs e)
{
Application["Name"] = txtName.Text;
Response.Redirect("receive .aspx");
}
protected void Button5_Click(object sender, EventArgs e)
{
Server.Transfer("receive .aspx");
}
public string GetName
{
get
{
return txtName.Text;
}
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class receive_ : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["Name"] != null)
Label1.Text = Request.QueryString["Name"];
if (Request.Cookies["Name"] != null)
Label4.Text = Request.Cookies["Name"].Value;
// The code below shows how to get the session value.
// This code must be placed in other page.
if (Session["Name"] != null)
Label6.Text = Session["Name"].ToString();
if (Application["Name"] != null)
Label8.Text = Application["Name"].ToString();
// You can declare this Globally or in any event you like
_Default w;
// Gets the Page.Context which is Associated with this page
w = (_Default)Context.Handler;
// Assign the Label control with the property "GetName" which returns string
Label10.Text = w.GetName;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["Name"] != null)
Label1.Text = Request.QueryString["Name"];
else if (Request.Cookies["Name"] != null)
Label4.Text = Request.Cookies["Name"].Value;
// The code below shows how to get the session value.
// This code must be placed in other page.
else if (Session["Name"] != null)
Label6.Text = Session["Name"].ToString();
else if (Application["Name"] != null)
Label8.Text = Application["Name"].ToString();
else if(Context.Handler is _Default)
{
// You can declare this Globally or in any event you like
_Default w;
// Gets the Page.Context which is Associated with this page
w = (_Default)Context.Handler;
// Assign the Label control with the property "GetName" which returns string
Label10.Text = w.GetName;
}
}