05.27.08

Passing data from one page to other in asp.net

Posted in asp.net at 12:56 am by admin

1)Query String
2)Cookies
3)Sessions

ParentPage.aspx
——————-

Server.Transfer(”ChildPage.aspx?Name=” + txtName.Text);

//Using Response.Redirect
Response.Redirect(”ChildPage.aspx?Name=” + txtName.Text);

//Using Cookies
HttpCookie cName = new HttpCookie(”Name”);
cName.Value = txtName.Text;
Response.Cookies.Add(cName);
Response.Redirect(”ChildPage.aspx”);

//Using Sessions
Session["Name"] = txtName.Text;
Response.Redirect(”Childpage.aspx”);

ChildPage.aspx
—————-

//using Response.Redirect
if (Request.QueryString["Name"] != null)
Label1.Text = Request.QueryString["Name"];

//Using Cookies
if (Request.Cookies["Name"] != null)
Label1.Text = Request.Cookies["Name"].Value;

//Using Sessions
if (Session["Name"] != null )
Label1.Text = Session["Name"].ToString();

Leave a Comment

ss_blog_claim=a8ddc9ba1abeb4559c8e63eaf9888450