There are a few things you could do to improve this, and one you should do to fix your problem:
Firstly: replace all your separate button Click handlers with a common handler:
protected void NumberButton_Click(object sender, EventArgs e)
{
Button b = sender as Button;
if (b != null)
{
txtdisplay.Text = txtdisplay.Text + b.Text;
}
}
That makes your code a lot shorter, easier to read, and reliable!
Then, set up a routine called SetOperation:
private void SetOperation(ref bool op)
{
if (txtdisplay.Text != "")
{
multiply = false;
plus = false;
minus = false;
division = false;
op = true;
Session["firstNo"] = txtdisplay.Text;
txtdisplay.Text = "";
}
}
And call that in each operation button press:
protected void btnAdd_Click(object sender, EventArgs e)
{
SetOperation(ref plus);
}
protected void btnMinus_Click(object sender, EventArgs e)
{
SetOperation(ref minus);
}
And so on.
Secondly: When you press a operation key, you first need to check if there is a pending operation! I.e. If plus is true, or minus is true, or ...
Otherwise, you just throw away your previous work...
Hint: Could you check and call most of btnEqual_Click?