How can I use ASP.NET inline tags from within a block of JavaScript? For example:
<script type="text/javascript">
// Do some AJAX here, then redirect to a new page on the next line.
window.location = "/Movie/" + <%= html.encode(MovieName) %>;
</script>
Just like you have on the ASP.Net part, but you want it inside the quotes, like this:
window.location = "/Movie/<%= html.encode(MovieName) %>";
Since it echos out to the page, it will render like this:
window.location = "/Movie/MyMovie";
Outside the quotes it would look like this:
window.location = "/Movie/" + MyMovie;
//thinks MyMovie is a variable, not true!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With