处理从C#生成的HTML中嵌套引用 [英] dealing with nested quotes in html generated from c#
本文介绍了处理从C#生成的HTML中嵌套引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是第三方库,以显示工具提示,像这样:
i am using a 3rd party library to show tooltips, like so:
string tooltip = "test";
output.Write("onmouseover='Tip(\"" + test + "\");'"); // work fine :)
我在遇到类似下面的,我需要的报价情况问题格式:
i'm having problem with situations like the following where i need quotes for formatting:
string tooltip = "<span style='color:red;'>test</span>";
output.Write("onmouseover='Tip(\"" + test + "\");'"); // no working :(
我如何能逃脱在提示所需HTML引号,因此不破函数调用?
how can i escape the quotes needed for the html in the tooltip so it doesn't break the function call?
推荐答案
替换的任何实例与
&放大器; QUOT;
如下:
Replace any instance of "
with "
as follows:
test.Replace( "\"", """ )
这篇关于处理从C#生成的HTML中嵌套引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文