String[] Array; Session["Name"] = Array;
<%@ Page Language="C#" Debug="true" %> <script runat="server"> void Page_Load(Object sender , EventArgs e) { String[] myArray = new String[5]; myArray[0] = "abc"; myArray[1] = "def"; myArray[2] = "ghi"; myArray[3] = "jkl"; myArray[4] = "mno"; Session["mySession"] = myArray; int i; String[] myNewArray = (String[])Session["mySession"]; for(i = 0; i< myNewArray.GetUpperBound(0) ; i ++) { if(myNewArray[i] != null) { this.lblText1.Text = this.lblText1.Text + myNewArray[i] + "<br>"; } } } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - Session Object</title> </head> <body> <form runat="server"> <asp:Label id="lblText1" runat="server"></asp:Label><br /><br /> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท