如何使用C#删除<br/>标签?

时间:2012-12-10 18:54:30

标签: c# asp.net html

我有html模板,我等待将其附加到文本框,问题是要问如何从html文件中删除
标签并添加换行符 html模板示例

PHONE/REMOTE SUPPORT TICKET<br>
<br>
Support Type:  PHONE / REMOTE ACCESS / EMAIL<br>
CSL#:<br>
Clients Name:<br>
Clients Phone#:<br>
Clients Email:<br>
<br>
<br>
Clients Issue:<br>
<br>
<br>
<br>
<br>
Issues Resolved:<br>
Follow-up Required:<br>
On-Site/Shop Service Required:<br>
Support Time:<br>

C#:附加文本框txtb_Description

    protected void lnkb_clientRMA_Click(object sender, EventArgs e)
    {

        String text = File.ReadAllText(Server.MapPath("WebTemplates/seagate_rma.html"));
        txtb_Description.Text = WebUtility.HtmlDecode(text);
    }

1 个答案:

答案 0 :(得分:5)

你可以使用替换

    string txt = WebUtility.HtmlDecode(text);
    txt = txt.Replace("<br>", Controlchars.NewLine);
    txt = txt.Replace("<br/>", Controlchars.NewLine);
    txtb_Description.Text = txt;

或者,更复杂的RegularExpression取决于您的应用程序。