Marc Davis
asked on
Session variables included in quotes
Hi all,
I have a hopefully relatively quick question.
In javascript how can I used a session variable included in quotes?
For instance, I need something like:
"<%# Session["Test"] %>"
I found I cannot use:
'<%# Session["Test"] %>'
And ASP.NET chokes on an invalid character if I do:
"<%# Session['Test'] %>"
"Test" can include text which has embedded quotes both single and doube already.
This appears to work:
"<%# Session["Test"] %>"
But the Test word is black because the preceding " is closing it off.
Any suggestions on how to work with the Session quotes within quotes?
Any assistance would be greatly appreciated.
Thanks
I have a hopefully relatively quick question.
In javascript how can I used a session variable included in quotes?
For instance, I need something like:
"<%# Session["Test"] %>"
I found I cannot use:
'<%# Session["Test"] %>'
And ASP.NET chokes on an invalid character if I do:
"<%# Session['Test'] %>"
"Test" can include text which has embedded quotes both single and doube already.
This appears to work:
"<%# Session["Test"] %>"
But the Test word is black because the preceding " is closing it off.
Any suggestions on how to work with the Session quotes within quotes?
Any assistance would be greatly appreciated.
Thanks
Try this one:
"<%= Session['Test'] %>"
"<%= Session['Test'] %>"
ASKER
mroonal, yep I would think that too but I got an error on an invalid statement in asp.net when I did that.
paulmacd, I'm trying to use it in an IF statement.
if ( "<%# Session["Test"] %>" == "" )
{
Again, the above works and is doing everything as expected when the page runs BUT in the IDE it's showing the Test as black.
paulmacd, I'm trying to use it in an IF statement.
if ( "<%# Session["Test"] %>" == "" )
{
Again, the above works and is doing everything as expected when the page runs BUT in the IDE it's showing the Test as black.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah, I'm with you on that. It just didn't make sense why it did. And in all honesty, I really didn't think twice about it when I did it.
I was just wondering which is why I posted the question as to how it would've/should've been done.
So, any thoughts/ideas would be great.
I was just wondering which is why I posted the question as to how it would've/should've been done.
So, any thoughts/ideas would be great.
ASKER
It was working so for all tense and purposes, your right...if it works don't worry about it.
Thanks!
Thanks!
<%# Session['Test'] %>
Are you using it as a literal? Can you post the context in which you're trying to get it to work?