I have a TextChanged Even on a textbox and when I enter data into it, it updates another textbox which in turn is supposed to fire a TextChanged Event, but it is not firing until I put my cursor in the TextBox. Is there a solution to this?
Code for updating the Extended Price when Qty Changes:
protected void txtQty1_TextChanged(object sender, EventArgs e)
{
if (txtQty1.Text != string.Empty && txtUnitPrice1.Text != string.Empty)
{
int qty = Convert.ToInt32(txtQty1.Text);
double unitPrice = Convert.ToDouble(txtUnitPrice1.Text);
double extendTotal1 = qty * unitPrice;
txtExtPrice1.Text = extendTotal1.ToString();
}
}
Code for updating the extending price When Unit Price changes:
protected void txtUnitPrice1_TextChanged(object sender, EventArgs e)
{
if (txtQty1.Text != string.Empty && txtUnitPrice1.Text != string.Empty)
{
int qty = Convert.ToInt32(txtQty1.Text);
double unitPrice = Convert.ToDouble(txtUnitPrice1.Text);
double extendTotal1 = qty * unitPrice;
txtExtPrice1.Text = extendTotal1.ToString();
}
}
Finally, this should update the Grand Total When Extending Price Changes:
protected void txtExtPrice1_TextChanged(object sender, EventArgs e)
{
if (txtExtPrice1.Text != string.Empty)
{
double extendedTotal1 = Convert.ToDouble(txtExtPrice1.Text);
double grandTotal = Convert.ToDouble(txtGrandTotal.Text);
grandTotal += extendedTotal1;
txtGrandTotal.Text = grandTotal.ToString();
}
}
Is it true that I should probably make Grand Total a Static Variable?