Reputation: 285
I have a Text box and i want to generate automatic number in this on page load.
I am trying this code :
static int i = 1000;
TextBox1.Text = i.ToString();
i++;
But when i again sign-in in my page it again start with 1000. I want it to generate number from where when logout from page.
thanks
Upvotes: 0
Views: 1475
Reputation: 1082
use Random class for this like
private static Random objRandom = new Random();
public int GetRandomNo()
{
return objRandom.Next();
}
Upvotes: 0
Reputation: 39248
You have to store the variable somewhere to persist it between sessions. The most common choice is storing it in a database
Upvotes: 2