Faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 20 people (35%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How to Pass a Session variable used in Script to Asp.Net Page?

Apr 8th, 2008 18:36
ha mo, Dave Clark, sabareeswaren A,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sab,
     This is not a JavaScript question -- as JavaScript cannot see 
(has no direct access to) ASP Session variables (.NET or otherwise).  
If you're asking how to pass the value of such a Session variable to 
JavaScript, now that is a different question.  That could be 
accomplished as follows:
<script type="text/javascript">
<!--//
var ASPvar = '<%=Session("MyVar")%>';
//-->
</script>
     It could also be accomplished as follows:
<script type="text/javascript">
<!--//
<%
    Response.Write "var ASPvar = '" & Session("MyVar") & "';" & vbCrLf
%>
//-->
</script>
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com