C # Remove the Code of all HTML tags | remove the HTML Tag Code
Public String nohtml (string htmlstring) // remove the HTML tag
{< br> // Delete the script
htmlstring = RegEx. replace (htmlstring, @ " "," ", regexoptions. ignorecase);
// delete HTML
htmlstring = RegEx. replace (htmlstring, @ "<(. [^>] *)> "," ", regexoptions. ignorecase);
htmlstring = RegEx. replace (htmlstring, @ "([\ r \ n]) [\ s] +", "", regexoptions. ignorecase);
htmlstring = RegEx. replace (htmlstring, @ "-->", "", regexoptions. ignorecase);
htmlstring = RegEx. replace (htmlstring, @ "
Htmlstring = RegEx. Replace (htmlstring, @ "& (quot | #34);", "\" ", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& (Amp | #38);", "&", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& (LT | #60);", "<", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& (GT | #62);", ">", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& (nbsp | #160);", "", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& (iexcl | #161);", "\ xA1", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& (cent | #162);", "\ xa2", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& (pound | #163);", "\ xa3", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& (copy | #169);", "\ xa9", regexoptions. ignorecase );
Htmlstring = RegEx. Replace (htmlstring, @ "& # (\ D +);", "", regexoptions. ignorecase );
Htmlstring. Replace ("<","");
Htmlstring. Replace ("> ","");
Htmlstring. Replace ("\ r \ n ","");
Htmlstring = httpcontext. Current. server. htmlencode (htmlstring). Trim ();
Return htmlstring;
}