asp.net - Access Session List in javascript -


.aspx.cs:

list<someobject> items = whatever.getlist();  

session["records"] = items;

if access session in javascript file gives me string

'system.collections.generic.list`1[someobject]' 

.js function:

var records = '<%= session["records"] %>'; 

how can convert session array? thanks

you have iterate through array , print right values:

var records = [];  <%      foreach(var item in (list<someobject>)session["records"]) {  %>  records.push('<%= item.propertyname %>');  <%      } %> 

now got array in script values.

to array of objects { property1: "value1", property2: "value2" }, stands same structur of c# object, example, have use reflection.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -