Redirect.aspx 前台
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Redirect.aspx.cs" Inherits="Redirect" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
用户名:<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
<asp:RadioButtonList ID="rdoltStatus" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="teacher">教师</asp:ListItem>
<asp:ListItem Value="student">学生</asp:ListItem>
</asp:RadioButtonList>
<asp:Button ID="btnSubmit" runat="server" OnClick="BtnSubmit_Click" text="确定"/>
</form>
</body>
</html>
Redirect.aspx后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Redirect : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BtnSubmit_Click(object sender, EventArgs e)
{
if (this.rdoltStatus.SelectedValue == "teacher")
{
//以查询字符串形式传递用户名信息并且被重定向到Teacher.aspx
Response.Redirect("~/Teacher.aspx?name=" + this.txtName.Text);
}
else
{
Response.Redirect("~/Student.aspx?name=" + this.txtName.Text);
}
}
}
Teacher.aspx前台
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Teacher.aspx.cs" Inherits="Teacher" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="forml" runat="server">
<div>
<asp:Label ID="lblMsg" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Teacher.asp后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Teacher : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.lblMsg.Text = Request.QueryString["name"] + " 老师,欢迎您";
}
}