Reputation: 23
i'm just want to know is there any way to get the custom type value from session variable in jquery?
for example. i have a class named user.
public class user{
public string userid;
public string username;
}
public static class Abc
{
public static List <user> user; //user type list
}
and in session variable i have session["userclass"] = Abc.user;
now the question is how to get value from this session variable using jquery.
i know about var abc = <%=session["variablename"]%>
but how to get value of the user class variables using above session variable in jquery?
Upvotes: 0
Views: 345
Reputation: 131
// ${FEEDBACK_QUESTION_IDS} this is session attribute name in controller
<script type="text/javascript">
$(document).ready(function() {
window.questionIdsList = [];
var i = 0;
<c:forEach items="${FEEDBACK_QUESTION_IDS}" var="queId">
questionIdsList[i] = parseInt(${queId});
i++;
</c:forEach>
});
</script>
finally we can use "window.questionIdsList" as same as array
Upvotes: 1
Reputation: 762
Because you put: "session["userclass"] = Abc.user;",
session["userclass"] is a list, not a user object.
You can code as followings:
List u = session["userclass"] as List;
User firstone = u[0] as user;
string id = firstone.userid;
Upvotes: 0