Monday, May 25, 2009

Navigation From One Page to Another Page with Data.














Navigation From One Page to Another Page with Data.


There are various ways to send the data from one page to other

1> Using QueryString.

e.g.
In first page you can write as follows :

Response.Redirect("mypage.aspx?id=" + value from control or variable or anystring);
mypage.aspx?id=10


Above dummy my page now contains id as the query string
and
It can be retrieved on the other page as follows :

string id = Request.QueryString["id"].ToString();

2> Using Session.
e.g. You can create session in first page like.

Session["id"] = value from control or variable or anystring;
and you can retrive it from other page as following:

string id = Session["id"].ToString();

3>Using Cookies
e.g. You can write cookie as in first page as follows :

Response.Cookies["id"].Value = value from control or variable or anystring;
and to retrive cookie you can request it as follows:

string id = Request.Cookies["BackgroundColor"].Value.ToString();

No comments:

Post a Comment