开发者

Declare HTML tag as a string in VB.NET

I'm trying to assign the following HTML as a value to variable type string

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

        D开发者_JS百科im htmltag = "$("#close").click(function(){$.notifyBar({ html: "Click 'close' to hide notify bar", close: true, delay: 1000000 });});"

I got a lot error message about the quotation in the string.


You need to use escape characters on the quotations otherwise they break the variable input. The VB.net escape for quotations is double quote:

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

In your example, the compiler would see the string as:

Dim htmltag = "$("

With lots of unknown stuff after it!

Other languages have different escape characters, javascript for example is backslash.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜