为什么我在代码中声明我的字符串会导致以下错误?有解决方法吗?
代码:
<script runat="server">
Protected Sub form1_Load(sender As Object, e As System.EventArgs)
Dim x As String = "</script>"
Response.Write(x)
End Sub
</script>
错误:语句不能出现在方法体中。方法结束。
注意:以下页面没有解决我的问题,而是导致在我的页面中输出字符串<\/script>
。 (VB.NET hates </script> tag in string literal)
答案 0 :(得分:0)
尝试:
<script runat="server">
Protected Sub form1_Load(sender As Object, e As System.EventArgs)
Dim x As String = "</" + "script>"
Response.Write(x)
End Sub
</script>