如何在字符串中插入html [英] how to insert html in a string
本文介绍了如何在字符串中插入html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否可以使用C#将HTML插入字符串中.
I am wondering if it is possible to have HTML be inserted into a string using C#.
推荐答案
作为将创建的HtmlTable设置为字符串的方法的示例.
as example a method that sets a created HtmlTable into a string.
public class HTMLTableToString
{
public static String Convert(Table table)
{
StringWriter stringWriter = new StringWriter();
using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
{
table.RenderControl(writer);
}
return stringWriter.ToString();
}
}
是的.
string s = "<a href=\"http://www.codeproject.com/Questions/342157/how-to-insert-html-in-a-string\">how to insert html in a string</a>[<a href=\"http://www.codeproject.com/Questions/342157/how-to-insert-html-in-a-string\" target=\"_blank\" title=\"New Window\">^</a>]";
这篇关于如何在字符串中插入html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文