0

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?

2 Answers 2

1
// ${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
Sign up to request clarification or add additional context in comments.

Comments

0

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;

3 Comments

thanx for your reply. but i want it in jquery......is there any way to get that value from jquery.
You have to write server side code so jquery calls it to get session object.
unfirtunately,you can access custom types in javascript via session variable. Keep a separate session variable to get that specific value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.