Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use a VB variable inside of an Embedded Javascript section?

Is it possible to do something like this:

<% Dim foo as string = "bar" %>

<script type="text/javascript">
    var baz = <%=foo %>
</script>

Where the <script> tag is embedded on my index page?

like image 932
Anders Avatar asked Nov 05 '08 14:11

Anders


1 Answers

Yes, but make sure you put quotes around it and a semicolon:

var baz = '<%=foo %>';
like image 171
Kon Avatar answered Oct 27 '22 22:10

Kon