protected void Button1_Click(object sender, EventArgs e) //A页面
{
//Response对象的Redirect方法重定向的功能.并向重定向的url传递参数
string name = txtname.Text.Trim();
string sex = "先生";
if (RadioButton2.Checked)
sex = "小姐";
Response.Redirect("Welcome.aspx?Name="+name+"&Sex="+sex);
}
public partial class Welcome : System.Web.UI.Page //B页面
{
protected void Page_Load(object sender, EventArgs e)
{
string name=Request .Params["Name"];
string sex=Request .Params["Sex"];
Response.Write("欢迎"+name+sex+"!");
}
}
本文介绍了一个简单的ASP.NET应用程序中如何实现从一个页面(A页面)通过按钮点击跳转到另一个页面(B页面),并在跳转过程中传递姓名和性别参数。通过Response.Redirect方法进行页面重定向,并附带URL参数;在目标页面中使用Request.Params获取这些参数并显示欢迎信息。
8593

被折叠的 条评论
为什么被折叠?



