In my ASP.NET (VB.NET) application, I have a Session variable containing a HashTable.
Dim products As Hashtable = New Hashtable
products("example") = "One product"
Session("products") = products
Now, I am trying to retrieve the value of products("example") in client-side using JavaScript.
My attempt:
<SCRIPT>
function ShowSessionValue() {
// create a new object
var sessionHashT = {};
// assign the HashTable stored in Session("products") to "sessionHashT"
sessionHashT= '<%=Session("products")%>';
// All alerts show "undefined" (although no errors are thrown):
alert(sessionHashT("example"));
alert(sessionHashT(example));
alert(sessionHashT.example);
};
</SCRIPT>
While debugging, I noticed that the value of sessionHashT is :
sessionHashT = 'System.Collections.Hashtable';
How can I access the values of the HashTable using JavaScript?