预期语句结束...VB.NET
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24947728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
End of Statement Expected...VB.NET
提问by coderatlarge
I am trying to open a new window on the client side from vb.net using:
我正在尝试使用以下方法从 vb.net 在客户端打开一个新窗口:
Dim webaddress as String
webaddress = "window.open("http://www.google.com")"
Page.Clientscript.RegisterStartupScript(Me.GetType(), "newpage", webaddress, True)
I am getting an error "End of statement expected" in line no. 2... Please help. I have tried all sorts of combinations.
我在第 1 行收到错误“预期语句结束”。2...请帮忙。我尝试了各种组合。
回答by NeverHopeless
You should handle such scenarios using String.Format
, for clear understanding of where the quotes "
should be specified:
您应该使用 处理此类情况String.Format
,以便清楚地了解"
应在何处指定引号:
webaddress = String.Format("window.open(""{0}"")", "http://www.google.com")
回答by shree.pat18
You need to escape the double quotes in the URL, like so:
您需要转义 URL 中的双引号,如下所示:
webaddress = "window.open(""http://www.google.com"")"