<form id="form1" runat="server"> <div> <table> <tr> <td >用户名:</td> <td><asp:TextBox runat="server" ID="txtName"/></td> </tr> <tr> <td >性别:</td> <td ><asp:TextBox runat="server" ID="txtSex"/></td> </tr> <tr> <td> </td> <td><asp:Button runat="server" ID="btnRegister" Text="注册" OnClick="btnRegister_Click" /></td> </tr> </table> </div> </form>
PRotected void btnRegister_Click(object sender, EventArgs e) { string strname = this.txtName.Text; string sex = ""; if (txtSex.Text == "男") { sex = "先生"; } else if (txtSex.Text == "女") { sex = "女士"; } Response.Redirect("Index.aspx?sName=" + strname + "&Sex=" + sex); }
protected void Page_Load(object sender, EventArgs e) { string name = Request.QueryString["sName"]; string sex = Request.QueryString["Sex"]; Response.Write(name + " " + sex +"欢迎注册"); }
新闻热点
疑难解答