Simple question about C# if else statement
- by ilkdrl
Iam doing a simple website and when i press button, i should see weight in label.. i see but if text.maxlenght 6, i should see ERROR message in same label but repeat see weight in label. How can i solve this problem?
protected void Button1_Click(object sender, EventArgs e)
{
double sayi1, sayi2, sayi3, hesap, sonuc;
sayi1 = Convert.ToDouble(Tb1.Text);
sayi2 = Convert.ToDouble(Tb2.Text);
sayi3 = Convert.ToDouble(Tb3.Text);
if (Tb1.MaxLength > 6 || Tb2.MaxLength > 6)
{
lbl1.Text = "ERROR.";
}
else
{
hesap = (((sayi1 - ((sayi1 - sayi2) / 2)) * ((sayi1 - sayi2) / 2)) / 40);
sonuc = (hesap * sayi3) / 100;
lbl1.Text = sonuc.ToString() + "kg";
}
}