一:用过的:

(1)通过URL链接地址传递 (加?..多个参数时加&para2=value中间不能有空格如href="receive.aspx?username=honge&pwd=123")

send.aspx:
        //或者页面<a href="receive.aspx?username=honge"></a>
        protected void Button1_Click(object sender, EventArgs e)
        {     Request.Redirect("receive.aspx?username=honge"); }
receive.aspx:
            string username = Request.QueryString["username"];这样可以得到参数值。
ps1:传递的参数默认都是string类型,所以不必加引号,也不必类型转换后传递,在接收方为string类型.<汉字除外>

ps2:当传递多个参数时,用&隔开,注意不能有空格

ps3:当传递汉字时,常常先进行类型转换, System.Web.HttpUtility.UrlEncode("你好!");

(2) 通过session
send.aspx:
        protected void Button1_Click(object sender, EventArgs e)
        { Session["username"] = "honge"; Request.Redirect("Default2.aspx"); }
receive.aspx:
         string username = Session["username"];     这样可以得到参数值。

(3)通过cook:

send:
    Request.Cookies.Add(new HttpCookie("cookie_stop2_class","education"));
receive:
    HttpCookie myCook = Request.Cookies["cookie_stop2_class"];
    if(myCook!= null){
        string str =myCook.Value;  //str = education;

    }

 

 

(4)通过Application
send.aspx:
         protected void Button1_Click(object sender, EventArgs e)
         { Application["username"] = "honge"; Request.Redirect("Default2.aspx"); }
receive.aspx: string username = Application["username"];这样可以得到参数值。

(5)通过Server.Transfer
send.aspx:
         public string Name { get { return "honge"; } }
         protected void Button1_Click(object sender, EventArgs e)
         { Server.Transfer("Default2.aspx"); }
 receive.aspx:
         send d = Context.Handler as send ;
         if (d != null) { Response.Write(d.Name);}

相关文章:

  • 2022-12-23
  • 2022-02-04
  • 2021-12-17
  • 2021-07-27
  • 2021-10-05
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-21
  • 2022-02-17
  • 2021-11-28
  • 2021-10-02
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案