<%@ Import Namespace="System.Collections.Specialized"%> <%@ Page Language="C#" Debug="true" %> <script runat="server"> void Page_Load(object sender, EventArgs e) { StringDictionary objDict; int i; objDict = new StringDictionary(); objDict.Add("white", "#FFFFFF"); objDict.Add("black", "#000000"); objDict.Add("red", "#FF0000"); objDict.Add("yellow", "#FFFF00"); objDict.Add("green", "#00FF00"); Session["mySession"] = objDict; this.lblText.Text = "StringDictionary Created <a href=AspNetStringDictionarySession2.aspx>click here</a> to view"; } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - StringDictionary</title> </head> <body> <form id="form1" runat="server"> <asp:Label id="lblText" runat="server"></asp:Label> </form> </body> </html>
<%@ Import Namespace="System.Collections.Specialized"%> <%@ Page Language="C#" Debug="true" %> <script runat="server"> void Page_Load(object sender, EventArgs e) { StringDictionary objDict; int i; objDict = (StringDictionary)(Session["mySession"]); foreach(String lsItem in objDict.Keys) { this.lblText.Text = this.lblText.Text + "Key = " + lsItem + ", Value = " + objDict[lsItem] + "<br>"; } } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - StringDictionary</title> </head> <body> <form id="form1" runat="server"> <asp:Label id="lblText" runat="server"></asp:Label> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท