我想将标签输出从aspx/aspx.cs中的一个页面转移到另一个页面



底部的aspx源是我在Order.aspx中的标签

<asp:Label ID="lblGrandTotal" runat="server" Visible="False"></asp:Label>

我在Order.aspx.cs中实现lblGrandTotal (Label)输出的代码是

protected void Button1_Click1(object sender, EventArgs e)
{
double Price = 0;
double Tax = 0;
double TotalPriceAir = 0;
double TotalPricePro = 0;
double GrandTotal = 0;
btn_ViewOrder.Visible = true;
Button3.Visible = true;

if (RadioButtonAir2019one.Checked == true)
{
Price = Convert.ToDouble(TextBoxAir2019.Text);
Price = Price * 739;
Tax = Price * 0.07;
TotalPriceAir = Price + Tax;
GrandTotal = TotalPriceAir + TotalPricePro;
lblSubTotalAir2019.Text = "Subtotal: $" + Price;
lblGSTAir.Text = "GST (7%): " + Tax;
lblTotalPriceAir.Text = "Total Price: " + TotalPriceAir;
lblGrandTotal.Text = "Grand Total: " + GrandTotal;
}
if (RadioButtonAir2019two.Checked == true)
{
Price = Convert.ToDouble(TextBoxAir2019.Text);
Price = Price * 739;
Tax = Price * 0.07;
TotalPriceAir = Price + Tax;
GrandTotal = TotalPriceAir + TotalPricePro;
lblSubTotalAir2019.Text = "Subtotal: $" + Price;
lblGSTAir.Text = "GST (7%): " + Tax;
lblTotalPriceAir.Text = "Total Price: " + TotalPriceAir;
lblGrandTotal.Text = "Grand Total: " + GrandTotal;
}
if (RadioButtonAir2020one.Checked == true)
{
Price = Convert.ToDouble(TextBoxAir2020.Text);
Price = Price * 989;
Tax = Price * 0.07;
TotalPriceAir = Price + Tax;
GrandTotal = TotalPriceAir + TotalPricePro;
lblSubTotalAir2020.Text = "Subtotal: $" + Price;
lblGSTAir.Text = "GST (7%): " + Tax;
lblTotalPriceAir.Text = "Total Price: " + TotalPriceAir;
lblGrandTotal.Text = "Grand Total: " + GrandTotal;
}
if (RadioButtonAir2020two.Checked == true)
{
Price = Convert.ToDouble(TextBoxAir2020.Text);
Price = Price * 989;
Tax = Price * 0.07;
TotalPriceAir = Price + Tax;
GrandTotal = TotalPriceAir + TotalPricePro;
lblSubTotalAir2020.Text = "Subtotal: $" + Price;
lblGSTAir.Text = "GST (7%): " + Tax;
lblTotalPriceAir.Text = "Total Price: " + TotalPriceAir;
lblGrandTotal.Text = "Grand Total: " + GrandTotal;
}
if (RadioButtonPro2020one.Checked == true)
{
Price = Convert.ToDouble(TextBoxPro2020.Text);
Price = Price * 1219;
Tax = Price * 0.07;
TotalPricePro = Price + Tax;
GrandTotal = TotalPriceAir + TotalPricePro;
lblSubTotalPro2020.Text = "Subtotal: $" + Price;
lblGSTPro.Text = "GST (7%): " + Tax;
lblTotalPricePro.Text = "Total Price: " + TotalPricePro;
lblGrandTotal.Text = "Grand Total: " + GrandTotal;
}
if (RadioButtonPro2020two.Checked == true)
{
Price = Convert.ToDouble(TextBoxPro2020.Text);
Price = Price * 1219;
Tax = Price * 0.07;
TotalPricePro = Price + Tax;
GrandTotal = TotalPriceAir + TotalPricePro;
lblSubTotalPro2020.Text = "Subtotal: $" + Price;
lblGSTPro.Text = "GST (7%): " + Tax;
lblTotalPricePro.Text = "Total Price: " + TotalPricePro;
lblGrandTotal.Text = "Grand Total: " + GrandTotal;
}
if (RadioButtonPro2021one.Checked == true)
{
Price = Convert.ToDouble(TextBoxPro2021.Text);
Price = Price * 1478;
Tax = Price * 0.07;
TotalPricePro = Price + Tax;
GrandTotal = TotalPriceAir + TotalPricePro;
lblSubTotalPro2021.Text = "Subtotal: $" + Price;
lblGSTPro.Text = "GST (7%): " + Tax;
lblTotalPricePro.Text = "Total Price: " + TotalPricePro;
lblGrandTotal.Text = "Grand Total: " + GrandTotal;
}
if (RadioButtonPro2021two.Checked == true)
{
Price = Convert.ToDouble(TextBoxPro2021.Text);
Price = Price * 1478;
Tax = Price * 0.07;
TotalPricePro = Price + Tax;
GrandTotal = TotalPriceAir + TotalPricePro;
lblSubTotalPro2021.Text = "Subtotal: $" + Price;
lblGSTPro.Text = "GST (7%): " + Tax;
lblTotalPricePro.Text = "Total Price: " + TotalPricePro;
lblGrandTotal.Text = "Grand Total: " + GrandTotal;
}

我希望lblGrandTotal和lblGrandTotal2 (Label)都有这个输出但是lblGrandTotal2在另一个web表单中也就是checkout。aspx

<asp:Label ID="lblGrandTotal2" runat="server" ></asp:Label>

在Order.aspx.cs中,我试图将lblGrandTotal输出转移到Checkout.aspx.cs,但它不工作

protected void btn_Payment_Click(object sender, EventArgs e)
{
Response.Redirect("Checkout.aspx");
Response.Redirect("Checkout.aspx?id=" + lblGrandTotal.Text);
}

点击付款按钮后,它将转到另一个页面,这是Checkout。Aspx和我在这段代码中键入键试图链接标签但它不起作用

protected void Page_Load(object sender, EventArgs e)
{
lblGrandTotal2.Text = Request.QueryString["id"];
}

我想实现lblGrandTotal和lblGrandTotal2标签在不同的web形式有相同的输出。

好的,你应该有工作。然而,这看起来不正确:

protected void btn_Payment_Click(object sender, EventArgs e)
{
Response.Redirect("Checkout.aspx");
Response.Redirect("Checkout.aspx?id=" + lblGrandTotal.Text);
}

应该是:

protected void btn_Payment_Click(object sender, EventArgs e)
{
Response.Redirect("Checkout.aspx?id=" + lblGrandTotal.Text);
}

相关内容

  • 没有找到相关文章

最新更新