access session value in js file

Posted by Rajarbind under ASP.NET on 10/21/2008 | Views : 5716 | Status : [Member] | Replies : 1
Hello,
I have created hidden field and assigning session value in in code behind .But i unable to get value in js file . I am calling that value like
document.getElementById('hdnSexpression').value = <% = Session["sExpression"] %>; but it is generation syntax error. Please suggest me how to get that value.

Arbind.




Responses

Posted by: Poster on: 10/21/2008 [Member] Starter

Up
0
Down
Are you writing this code in .js file (document.getElementById('hdnSexpression').value = <% = Session["sExpression"] %>;)?

Try writing it in the .aspx file wrapping with <script> tag.

like
<script language="javascript">
document.getElementById('hdnSexpression').value = <% = Session["sExpression"] %>;
</script>

Hopefully, this should work. It would be better if you keep this inside single quote like '<% = Session["sExpression"] %>';

Plesae let me know.

Rajarbind, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response