Monday, June 3, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  13] [ 4]  / answers: 1 / hits: 23529  / 12 Years ago, tue, january 8, 2013, 12:00:00

I'm not able to access the variable in my .js file



the code i have at the top of the page is:



<script type=text/javascript>
privilage = '<%=Session[privilage]%>';
</script>


then i want to access privilage in my .js file.



i just want to alert this at the moment. would i be able to do this?



thanks


More From » c#

 Answers
12

You have to store session Value in HiddenField.
After that You can Access the HiddneFieldValue in your JS



 <script type=text/javascript>
document.getElementById('hdnField').value = '<%=Session[privilage]%>';
</script>

[#81012] Monday, January 7, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kourtney

Total Points: 368
Total Questions: 103
Total Answers: 85

Location: Bonaire
Member since Sat, May 1, 2021
3 Years ago
kourtney questions
Sun, Oct 4, 20, 00:00, 4 Years ago
Tue, Oct 29, 19, 00:00, 5 Years ago
Thu, Apr 4, 19, 00:00, 5 Years ago
Fri, Mar 1, 19, 00:00, 5 Years ago
;