aspx页面
<body> <form id="form1" runat="server"> <div> 用户名:<input type="text" name="txtname" /> <input type="submit" value="提交" /> </div> </form> </body>
aspx.cs代码
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string userName = Request.Form["txtname"];//获取用户名 Session["name"] = userName; Response.Redirect("testUser.aspx"); } }
跳转页面testUser.aspx.cs代码
protected void Page_Load(object sender, EventArgs e) { if (Session["name"] != null) { Response.Write(Session["name"]); } }