Hopefully this is really obvious, but forgive me. I havent used .net for a while, and this isnt my home dev machine, so I cant look at old code.
I have a simple form which I am using to test various ideas out on at present.
in the pageLoad I have a load of variables being set
But when these are used late on in the program, in response to button presses and so on, the PostBack occurs, steps over the initialisation code, but all my arrays are undefined and my int has reset to 0
So am I doing something wrong here in my assumption that the variables should stay set? Or do I need to come up with some method of caching these variables on the server (In which case I either set them every pass, save in a DB, or persist them I guess)
K
I have a simple form which I am using to test various ideas out on at present.
in the pageLoad I have a load of variables being set
Code:
protected int testInt;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
myArr = new ArrayList(10);
testInt = new int();
testInt = 5;
//Set the Array Name
myArr.Initialise();
}
}
But when these are used late on in the program, in response to button presses and so on, the PostBack occurs, steps over the initialisation code, but all my arrays are undefined and my int has reset to 0
So am I doing something wrong here in my assumption that the variables should stay set? Or do I need to come up with some method of caching these variables on the server (In which case I either set them every pass, save in a DB, or persist them I guess)
K