我需要使用 C# 在 ASP.NET 中使用多个 response.redirect

I need to use multiple response.redirect in ASP.NET using C#

我正在编写一个学校程序,我正在尝试将 3 个输入字段移动到一个新页面。

我可以让 response.redirect 在一个领域工作,但不能更多。

当我单击按钮时,它会将我带到下一页,并且只会带出一个字段。不是我想要达到的 3。

谁能帮我右转?提前致谢...

第一页:

protected void btnEnterSelection_Click(object sender, EventArgs e)
{
    lblBookEntered.Visible = true;
    lblBookType.Visible = true;
    lblPurchaseType.Visible = true;
    lblBookEnteredText.Visible = true;
    lblBookTypeText.Visible = true;
    lblPurchaseTypeText.Visible = true;
    lblBookEntered.Text = "The book you entered is: ";
    lblBookEnteredText.Text = txtBoxBookTitle.Text;
    lblBookType.Text = "The book type is: ";
    lblBookTypeText.Text = drpDownType.Text;
    lblPurchaseType.Text = "The purchase type is: ";
    lblPurchaseTypeText.Text = drpDownPurchase.Text;
}

protected void btnPurchase_Click(object sender, EventArgs e)
{
    Response.Redirect("turtleDoxPurchase.aspx?bookName=" + txtBoxBookTitle.Text);
    Response.Redirect("turtleDoxPurchase.aspx?bookType=" + drpDownType.Text);
    Response.Redirect("turtleDoxPurchase.aspx?purchaseType=" + drpDownPurchase.Text);
}

第二页:

protected void Page_Load(object sender, EventArgs e)
{
    lblBookEntered.Visible = true;
    lblBookType.Visible = true;
    lblPurchaseType.Visible = true;
    lblBookEnteredText.Visible = true;
    lblBookTypeText.Visible = true;
    lblPurchaseTypeText.Visible = true;
    lblBookEntered.Text = "The book you entered is: ";
    lblBookEnteredText.Text = Request.QueryString["bookName"]; 
    lblBookType.Text = "The book type is: ";
    lblBookTypeText.Text = Request.QueryString["bookType"];
    lblPurchaseType.Text = "The purchase type is: ";
    lblPurchaseTypeText.Text = Request.QueryString["purchaseType"];

    lblCreditCard.Visible = true;
    txtBoxCreditCard.Visible = true;
    lblCreditCardChoice.Visible = true;
    rdoListCreditCard.Visible = true;
    btnSubmitPayment.Visible = true;
}

如果我对问题的理解正确,您正试图将三个值从第一页发送到第二页。在这种情况下,您可以使用来自 txtBoxBookTitle、drpDownType 和 DrpDownPurchase 的值构建查询字符串。该字符串应采用以下格式:

string queryString = "?bookName={txtBoxBookTitle}&bookType={drpDownType.Value}&purchaseType={DrpDownPurchase.Value}"

然后你可以将上面的字符串附加到你的

Response.Redirect("turtleDoxPurchase.aspx" + queryString);

希望对您有所帮助!