Search code examples
c#asp.nethtmltextwriter

HTMLTextWriter Remove Hyperlinks and formatting in C#


Some of my fields get exported as hyperlinks and I want it to format to standard font and remove hyperlinks. How do I do that in C#?


Solution

  • I used regular expression to remove the javascript behind the column which sorted it out.

    string html2 = Regex.Replace(sw.ToString(), @"(<input type=""javascript""\/?[^>]+>)", @"", RegexOptions.IgnoreCase);
    html2 = Regex.Replace(html2, @"(<a \/?[^>]+>)", @"", RegexOptions.IgnoreCase);
    Response.Write(html2.ToString());