locked
after posting I am losing the values of array RRS feed

  • Question

  • User-735851359 posted

    Hello,

    I created an array and filled that with random characters;

        int j=0;
    for(char k='a';k<='j';k++){ rnd[j] = k;
    j++; } var r = new Random(); char temp='a'; for(int k=0;k<n;k++){ int t = r.Next(n); temp = rnd[t]; rnd[t] = rnd[k]; rnd[k] = temp; }

    After posting I still need to keep the old values, but it change the values:

    if(IsPost){
        for(int i=1;i<=n;i++){ 
            ss = "s" + i.ToString();
            soru = Request[ss].AsInt();
            answers = answers + soru;
            if (soru == rnd[i-1]-'a'+1){
                count++;
            };
        }
    }

    how can I solve this problem?

    thanx

    Sunday, June 1, 2014 3:40 PM

Answers

  • User-1416423428 posted
    The internet is stateless. So whatever values in variables you have during your last run will be forgotten next time you run the page again.

    I'd suggest storing your array in a session variable after you've filled it up with values. Next time you need it, assign session variable back into an array.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 1, 2014 4:20 PM

All replies

  • User-1416423428 posted
    The internet is stateless. So whatever values in variables you have during your last run will be forgotten next time you run the page again.

    I'd suggest storing your array in a session variable after you've filled it up with values. Next time you need it, assign session variable back into an array.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 1, 2014 4:20 PM
  • User-735851359 posted

    Hello,

    I posted the values of the array and request them and used.

    thanx anyway

    Monday, June 2, 2014 6:22 AM