1

Here is my code :

var activitytaskid = "<%= Session['currentTask']%>";

Am not able to get the session value with following key, please help me out. Thanks

2
  • What is Session['currentTask']? Commented May 15, 2014 at 7:05
  • Where is that code? In a .js or .html file (that will not work as it is not processed by asp.net), or in an .aspx file (that should work, when you switch the quotes)? Commented May 15, 2014 at 7:22

2 Answers 2

3

Please try modifying your code.

var activitytaskid = '<%= Session["currentTask"]%>';

And remember this will contain rendered value. The value of activitytaskid will be initialized at the time page is rendered.

EDIT
Yes browser will show this string as session is server side so value will be rendered in javascript varaible.

So when you view source of html page, value will be displayed in plain text

Sign up to request clarification or add additional context in comments.

2 Comments

browser is displaying this whole as a string.
Sorry this is not working for me, so i just take the value of session in a hidden field and fetch that hidden value in js.
0

Is this java? If so that should read "session" with a lowercase 's'. If the case is correct, make sure you have set the currentTask session variable somewhere.

1 Comment

The question is tagged "C#" and "asp.net", so it's not java.

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.