首页 > 解决方案 > 如何在双引号内转义引号?

问题描述

我正在添加一个带有 html 的表格:

string _table = @"{
                        ""version"": {""number"": 2},
                        ""type"":""page"",
                        ""title"":""Table"", 
                        ""space"":{""key"":""" + postdata.key + @"""},
                        ""body"":{""storage"":{""value"":""<table><tbody><tr><th><p><strong>Project Basic Informations</strong></p></th></tr></tbody></table>"",""representation"":""storage""}}
                        }";

而且我想设置样式<th>colspan="2"因此标题跨越两列。

我尝试了以下方法,但它不起作用:
""<table> <tbody> <tr> <th colspan=""2""> <p><strong>Project Basic Informations</strong></p> </th>....""
<th colspan=\"2\"

有没有办法逃避双引号并让<th>colspan 属性起作用?

标签: c#html

解决方案


HTML 属性上的单引号也可以。你可以写<th colspan='2'>


推荐阅读