明日科技的asp.net重新复习(一)

通过url实现页面之间的信息传递

1.在Defaultaspx页面_Response.Redirect

        string name = this.TextBox1.Text;

        string sex = "先生";

        if (RadioButton2.Checked)
        {
            sex = "女士";
        }

 Response.Redirect("~/welcome.aspx?Name="+name+"&Sex="+sex);

2在Welcome页面_Request.Params

  string name = Request.Params["Name"];

    string sex = Request.Params["Sex"];

    Response.Write("欢迎"+name +sex+"!");

总结:Response.Redirect的参数类型为 string

在其中写入url

另一个页面通过 Request.Params请求参数

发布了251 篇原创文章 · 获赞 42 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_38992403/article/details/104347717