QueryString - 地址栏显示传值(get)
Request - 获取请求对象
Response - 响应对象
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Button1.Click += Button1_Click; } private void Button1_Click(object sender, EventArgs e) { //点击按钮 string s = TextBox1.Text;//接受用户输入的内容 Response.Redirect("Default2.aspx?aaa="+ s );// 跳转到Default2.aspx页面并将s传给Default2.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 Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Label1.Text= Request["aaa"];//用label1接受下传过来的值 } }
时间: 2024-09-30 05:16:06