How can you make the ASP.net Session Data available to a JavaScript method? I found this link when I googled. Anyone has a better trick that does not use the ScriptManager?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If ditching the ScriptManager is your aim, exposing the page method is still a good option, just use javascript that doesn’t rely on the ScriptManager js libraries.
I like the solution proposed in the linked page, but it might be a too wide open though. Maybe you want to create a strongly typed and controlled PageMethod for any/all Session items that you want to allow access to. That way you can’t access some secret Session value accidentally.
Also, I think you need to tag the PageMethod with
VB
C#
as I don’t think EnableSession is on by default.