我只是不明白,为什么输出不正确显示如何删除换行符
这里是我的视图代码
@model IEnumerable<TheSite.Post>
@{
ViewBag.Title = "Index";
Layout = null;
}
document.write('<table>
@foreach (var p in Model)
{
<tr>
<td>
<a href="@p.Url">@p.Title</a>
</td>
</tr>
}
</table>');
这里是输出:
document.write('<table>
<tr>
<td>
<a href="http://www.test.com">test</a>
</td>
</tr>
</table>');
这里我需要的输出:
document.write('<table><tr><td><a href="http://www.test.com">test</a></td></tr></table>');
我尝试使用stringbuilder,但输出被转义。
最后我用你的代码,替换所有换行符。Thnaks – Luke101