Reputation: 615
I am looking for a text editor for my asp.net mvc project. I was able to find a lot of text editor out there works pretty well.
What I am looking for is a editor that accept only regualr character like "I am a superman".
I do not want to save "<p><strong>I am a superman</strong></p>
" into my SQL table since I have to show it thru textbox(example : <%= Html.TextBox("Remark", Model.empExperience.Remark)%>
).
Let me know.
Upvotes: 0
Views: 502
Reputation: 13083
This is how you do it (to sum up the answers on the link Nathan provided):
private static readonly Regex StripHtml = new Regex("<[^>]*>", RegexOptions.Compiled);
/// <summary>
/// Strips all HTML tags from the specified string.
/// </summary>
/// <param name = "html">The string containing HTML</param>
/// <returns>A string without HTML tags</returns>
public static string StripHtmlTags(string html)
{
if (string.IsNullOrEmpty(html))
return string.Empty;
return StripHtml.Replace(html, string.Empty);
}
Upvotes: 1
Reputation: 24606
Seeing as you do not wish to allow HTML, your best bet is to simply have a means of stripping HTML from the provided input. There's no need to implement a custom text editor for this sort of thing.
Have a look at: How can I strip HTML tags from a string in ASP.NET?
Upvotes: 2