admin管理员组

文章数量:1352292

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?

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?

Share Improve this question asked Nov 5, 2008 at 14:26 AndersAnders 12.6k36 gold badges101 silver badges146 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

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

var baz = '<%=foo %>';

本文标签: aspnetCan I use a VB variable inside of an Embedded Javascript sectionStack Overflow