So I'm writing an ASP.NET MVC Web application and at the top of one of my razor pages i have this code:
<script type="text/javascript">
alert("@TempData["alertMessage"]");
</script>
If I understand the error
Unterminated string constant
correctly, it means I haven't closed the quotation marks. But if I look at the code it should be closed correctly right?
What is wrong about it?
You should use single
quotes in order to avoid the error
.
alert('@TempData["alertMessage"]');
With the other words you should wrap the statement within single quotes
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.