I have a JavaScript Variable that is set in my ASP.NET page as follows
<script type="text/javascript>
var MyVarable = <%=ASPNETVarable%>;
$(document).ready(function () {
alert(MyVarable);
}
</script>
Now this is simplified and on the back end code ASPNETVarable is set as
protected string ASPNETVarable="My Backend Value";
The page loads & runs correctly, but in Visual Studio the line
var MyVarable = <%=ASPNETVarable%>;
Shows that it's a "Syntax error", while it works, how do I remove this "syntax error" ?
尝试以下
var MyVarable = '<%=ASPNETVarable%>';
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.