【问题标题】:Declare HTML tag as a string in VB.NET在 VB.NET 中将 HTML 标记声明为字符串
【发布时间】:2010-07-11 04:24:16
【问题描述】:

我正在尝试将以下 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 });});"

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

【问题讨论】:

    标签: vb.net string string-constant


    【解决方案1】:

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

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

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

    Dim htmltag = "$("
    

    后面还有很多不为人知的东西!

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-19
      • 2013-05-27
      • 1970-01-01
      • 1970-01-01
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 2011-10-29
      相关资源
      最近更新 更多