I am wondering why when I declare a public Int that I implement everytime I reload the page, the int is always going to 1.
This is the code I use.
I declare the int before the page load. And every page load the int is 1. It should be 2, 3 etc …
public int countIdPrevious;
protected void Page_Load(object sender, EventArgs e)
{
countIdPrevious++;
}
It is because fields are not included in ViewState.
Turn this field into a ViewState-backed property and you’ll be fine.