Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
how to get Session value in external javascript file
Posted

1 solution

You cannot use server side expressions in your external javascript files.
You could declare a global variable in your aspx page that will hold the
value which will be used in your javascript file:

in front page :

<script type="text/javascript">
var sessionexternal= '<%= Session["sessionexterna"] %>';
</script>


and then you could use sessionexternal variable in your external javascript file function.
 
Share this answer
 
Comments
senthilnathan p 27-Jun-19 0:02am    
Hi sir ,

The above code is use in aspx page but it throw the error in external js file. pls give solution.
senthilnathan p 27-Jun-19 0:02am    
Hi sir ,

The above code is use in aspx page but it throw the error in external js file. pls give solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900