QueryString is a simple method for transferring values. It can display the transmitted values in the address bar of the browser. when one or more values with low security or simple data are passed, an array or object can be used.
Private void button#click (object sender, System. EventArgs e) {string url; url = "B. aspx? Name = "+ Lable1.Text;} c # code private void Page_Load (object sender, EventArgs e) in B. aspx {Lable2.Text = Request. QueryString [" name "];}
Query values are classified into post and get formats.
// Post request
String name = Request ["name"]. toString ();
String name = Request. Form. Get ("name"). toString ();
// Get request
String name = Request. QueryString ["name"]. toString ();
However, I found that both post and get values are available.
String name = Request ["name"]. toString ();
Application object Value passing
A. aspx c # code
private void Button1_Click(object sender, System.EventArgs e){ Application["name"]=Label.Text; Server.Transfer("b.aspx");}
B. aspx c # code
private void Page_Load(object sender, EventArgs e){ string name; Application.Lock(); name=Application["name"].ToString(); Application.UnLock();}
Use Session Variables
A. aspx c # code
private void Button1_Click(object sender, System.EventArgs e){ Session["name"]=Lable.Text; }
B. c # code in aspx
private void Page_Load(object sender, EventArgs e){ string name=Session["name"].ToString();}
Use Cookie object variables
A. C # code in aspx
private void Button1_Click(object sender, System.EventArgs e){ HttpCookie cn=new HttpCookie("name"); cn.Value=Lable.Text; Reponse.AppendCookie(cn); Server.Transfer("b.aspx");}
B. c # code in aspx
private void Page_Load(object sender, EventArgs e){ string name=Request.Cookie["name"].Value.ToString();}
Use the Server. Transfer () method
A. aspx c # code
public string Name{ get{return Lable1.Text;}}private void Button1_Click(object sender, System.EventArgs e){ Server.Transfer("b.aspx");}
B. aspx c # code
private void Page_Load(object sender, EventArgs e){ a newWeb; newWeb=(source)Context.Handler; string name; name=newWeb.Name;}