locked
Does anyone have examples of global variables avalible to all pages in VB RRS feed

  • Question

  • User-804896464 posted
    Thank you in advance for any responses/ advice.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p> I want to choose a variable and have it be available to all the other pages as a student number.  I have built a functional shopping cart before.  <o:p></o:p>Would it be best to declare a global variable and reference that value or create a shopping cart session type user and use that logic?<o:p></o:p> <o:p></o:p>Any suggestions and examples are more than welcome.<o:p></o:p>

     Thank you.

    <o:p> </o:p>

     

    Monday, March 30, 2009 3:23 PM

Answers

  • User-990694832 posted

    I would think just putting the value in the session should work well.

    Session("yourkey") = yourvalue

    DK

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 30, 2009 4:24 PM
  • User-1267218547 posted

    Hi,

    Thank you in advance for any responses/ advice. I want to choose a variable and have it be available to all the other pages as a student number. 

    Yes, you can use Session.

    Session["A"] = "A";

    Session["B"]=DateTime.Now;

    string str = Session["A"].ToString();

    DateTime time=(DateTime)Session["B"];

    but I recommend you study all states of the asp.net for keeping some datas of the application.

    All States in ASP.NET <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    http://forums.asp.net/p/1392899/2986337.aspx#2986337

    <o:p>If you have anything unclear, please feel free to let me know.</o:p>

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 31, 2009 11:41 PM

All replies

  • User-990694832 posted

    I would think just putting the value in the session should work well.

    Session("yourkey") = yourvalue

    DK

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 30, 2009 4:24 PM
  • User-1267218547 posted

    Hi,

    Thank you in advance for any responses/ advice. I want to choose a variable and have it be available to all the other pages as a student number. 

    Yes, you can use Session.

    Session["A"] = "A";

    Session["B"]=DateTime.Now;

    string str = Session["A"].ToString();

    DateTime time=(DateTime)Session["B"];

    but I recommend you study all states of the asp.net for keeping some datas of the application.

    All States in ASP.NET <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    http://forums.asp.net/p/1392899/2986337.aspx#2986337

    <o:p>If you have anything unclear, please feel free to let me know.</o:p>

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 31, 2009 11:41 PM