在VB.NET中将HTML标记声明为字符串

时间:2010-07-11 04:24:17

标签: vb.net string string-constant

我正在尝试将以下HTML作为值分配给变量类型字符串

    'here's the tag 
   '$("#close").click(function(){$.notifyBar({ html: "Click 'close' to hide notify bar", close: true, delay: 1000000 });});

        Dim htmltag = "$("#close").click(function(){$.notifyBar({ html: "Click 'close' to hide notify bar", close: true, delay: 1000000 });});"

我收到很多关于字符串中引号的错误消息。

1 个答案:

答案 0 :(得分:0)

您需要在引号上使用转义字符,否则会破坏变量输入。引用的VB.net转义是双引号:

Dim htmltag = "$(""#close"").click(function(){$.notifyBar({ html: ""Click 'close' to hide notify bar"", close: true, delay: 1000000 });});"

在您的示例中,编译器会将字符串视为:

Dim htmltag = "$("

之后有很多未知的东西!

其他语言有不同的转义字符,例如javascript是反斜杠。

相关问题