Samuel Toh

Samuel Toh

  • NA
  • 106
  • 14.4k

string.empty not working in html

Nov 16 2021 12:24 PM
if (ddlPhone.SelectedIndex == 0 && CheckBoxBlue.Checked && Radio64.Checked && txtQty.Text != string.Empty)
{
    Price = Convert.ToDouble(txtQty.Text);
    Price = Price * 1149;
    Tax = Price * 0.06;
    TotalPrice = Tax + Price;
    lblTotalSummary.Text = "DATE & TIME: " + DateTime.Now.ToString() + "<br>ITEMS ORDERED: iPhone 12 Mini<br>" + "&nbsp&nbsp&nbsp&nbspColor: Blue<br>"
        + "&nbsp&nbsp&nbsp&nbspStorage: 64GB<br>" + "&nbsp&nbsp&nbsp&nbspWarranty: 1 Year<br>" + "&nbsp&nbsp&nbsp&nbspQTY: " + txtQty.Text;
    lblTotal12.Text = Price.ToString();
    lbl12Tax.Text = Tax.ToString();
    lbl12Cost.Text = TotalPrice.ToString();
    //12 Alternative
    lblFake12.Text = "Price: $" + Price.ToString();
    lblFakeTax12.Text = "Tax: $" + Tax.ToString();
    lblFakeTotal12.Text = "Total: $" + TotalPrice.ToString();
    //Normal
    Application["Summary"] = lblTotalSummary.Text;
    Application["Summary12"] = lbl12Cost.Text;
    Application["SummaryTotal12"] = lblTotal12.Text;
    Application["SummaryTax12"] = lbl12Tax.Text;
    //12 Alternative
    Application["Fake12"] = lblFake12.Text;
    Application["FakeTax12"] = lblFakeTax12.Text;
    Application["FakeTotal12"] = lblFakeTotal12.Text;
    lblError.Text = "";
}
else
{
    lblError.Text = "Please choose a quantity!";
    lblTotalSummary.Text = "";
    lblTotal12.Text = "";
    lbl12Tax.Text = "";
    lbl12Cost.Text = "";
    lblFake12.Text = "";
    lblFakeTax12.Text = "";
    lblFakeTotal12.Text = "";
    return;
}

After running the code. The text "Please choose a quantity!" is still appearing even though txtQty is not empty. How do I resolve it? I am using HTML ASP.NET in visual studio 2017


Answers (3)