0

I'm trying to make it so that when a button is clicked it takes strings from two text boxes and converts them to doubles. However, every time I try to debug it, upon clicking the button the compiler tells me "input string was not in a correct format." I'm not really sure why it isn't working. Here's the code for the button click:

protected void btnCalculateSalary_Click(object sender, EventArgs e)
{
    double annualHours = 0.0;
    double payRate = 0.0;
    double annualSalary = 0.0;

    annualHours = Convert.ToDouble(lblAnnualHours.Text);
    payRate = Convert.ToDouble(lblPayRate.Text);

    annualSalary = annualHours * payRate;

    lblAnnualSalary.Text = "Annual Salary: $" + annualSalary.ToString("C");
}

1 Answers1

2

Are you maybe trying to parse the texts of the labels instead of the textboxe`s texts? The names lblAnnualHours and lblPayRate indicate that.

Flotto
  • 173
  • 1
  • 9