scope var

Last post 05-09-2008 11:15 PM by gbogea. 3 replies.

Sort Posts:

  • scope var

    05-08-2008, 9:38 PM
    • Loading...
    • lacu
    • Joined on 05-04-2003, 6:44 PM
    • Posts 9
    I need define an array to store selection of the user in the page.
    I am using masterpages.
    if a define the array  like

    public partial class KWPedidoPlantillaV2 : System.Web.UI.Page
    {
    private
    static ArrayList fliawebsaved = new ArrayList(); 
     .....

    the var is for all the session open.
    What must I do to define the var for only the user accesing the page.
    Thank you.

     

    Filed under:
  • Re: scope var

    05-08-2008, 10:18 PM
    Answer
    • Loading...
    • gbogea
    • Joined on 04-14-2008, 7:17 PM
    • Brazil
    • Posts 198

     You're right, using static will make the array shared between all users.

    You can create the array and store it in the user session:

    public partial class KWPedidoPlantillaV2 : System.Web.UI.Page
    {

        private ArrayList fliawebsaved;

        protected void Page_Load(object sender, EventArgs e)
        {
            fliawebsaved = Session["MyArray"] as ArrayList;
            if (fliawebsaved == null)
            {
                fliawebsaved = new ArrayList();
                Session["MyArray"] = fliawebsaved;
            }
        }

    Gabriel Bogéa (http://www.gbogea.com)
    -----------------
    Please 'Mark as Answer' the post(s) that helped you
  • Re: scope var

    05-09-2008, 4:47 PM
    • Loading...
    • lacu
    • Joined on 05-04-2003, 6:44 PM
    • Posts 9

    Thank you very much!

  • Re: scope var

    05-09-2008, 11:15 PM
    • Loading...
    • gbogea
    • Joined on 04-14-2008, 7:17 PM
    • Brazil
    • Posts 198

     No problem!

    If this post helped you, please click the Mark As Answer button. Thanks! 

    Gabriel Bogéa (http://www.gbogea.com)
    -----------------
    Please 'Mark as Answer' the post(s) that helped you
Page 1 of 1 (4 items)