Samuel Toh

Samuel Toh

  • NA
  • 106
  • 16.8k

Transferring output value in ASP.NET HTML - Edited

Nov 2 2021 5:45 AM

protected void btnSubmit_Click(object sender, EventArgs e)
{
    double Price = 0;
    double Tax = 0;
    double TotalPrice = 0;

    //iPhone 12 Mini
    if (ddlPhone.SelectedIndex == 0 && CheckBoxBlue.Checked && ddlStorage.SelectedIndex == 0)
    {
        Price = Convert.ToDouble(txtQty.Text);
        Price = Price * 1149;
        Tax = Price * 0.06;
        TotalPrice = Tax + Price;

        lblTotalSummary.Text = "DATE & TIME: " + DateTime.Now.ToString() + "ITEMS ORDERED: iPhone 12 Mini"+ "    Color: Blue" + "    Storage: 64GB" + "    Warranty: 1 Year" + "    QTY: " + txtQty.Text;
        lblTotal12.Text = Price.ToString();
        lbl12Tax.Text = Tax.ToString();
        lbl12Cost.Text = TotalPrice.ToString();
}

So above I have a picture for my design in ASP.NET HTML in Visual Studio 2017. My code is designed such a way that a user MUST key in the quantity they want for the iPhone. If the User does not key in the quantity or leave out any checkboxes, it will have an error later when clicking on the submit button. I was wondering how can i avoid that from happening?


Answers (4)