在.aspx文件:
<asp:TextBox id="txbAge" runat="server"></asp:TextBox>
<asp:TextBox id="txbName" runat="server"></asp:TextBox>
<asp:Button id="btnSubmit" runat="server" onclick="btnSubmit_Click" />
在aspx.cs文件:
protected void btnSubmit_Click(object sender, EventArgs e)
{
string age = txbAge.Text;
string name = txbName.Text;
string url = string.Format("~/anotherPage.aspx?age={0}&name={1}", age, name);
Response.Redirect(url);
}
在第二.aspx文件:
<aspx:Label id="lblAge" runat="server"></aspx:Label>
<aspx:Label id="lblName" runat="server"></aspx:Label>
在第二.aspx.cs文件:
protected void Page_Load(object sender, EventArgs e)
{
string age = string.Empty;
string name = string.Empty;
if(!String.IsNullOrEmpty(Request.QueryString["age"]))
age = Request.QueryString["age"];
if(!String.IsNullOrEmpty(Request.QueryString["name "]))
age = Request.QueryString["name "];
lblAge.Text = age;
lblName.Text = name;
}
這是路怎麼走在查詢字符串另一頁上這些值。
Mariusz
你究竟在做什麼?當我點擊提交按鈕時,顯示你的代碼 – Bas
輸入的值應該顯示在另一個網頁 –