user1800361
user1800361

Reputation:

how to remove <br> tag using C#?

I have html templates that I wait to append it to textbox the problem is want to ask how to remove the
tags from html file and add line break html template example

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#: to append textbox 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);
    }

Upvotes: 0

Views: 3745

Answers (1)

urlreader
urlreader

Reputation: 6605

you could use Replace

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

Or, more complex, RegularExpression, depends on your application.

Upvotes: 6

Related Questions