html - Check if HtmlString is whitespace in C# -


i've got wrapper adds header field whenever has value. field string holds html tinymce textbox.

requirement: header should not display when field empty or whitespace.

issue: whitespace in html rendered <p>&nbsp; &nbsp;</p>, technically it's not empty or whitespace value

i can't !string.isnullorwhitespace(model.contentfield.value) because have value, albeit whitespace html.

i've tried convert value onto @html.raw(model.contentfield.value) it's of type htmlstring, can't use string.isnullorwhitespace.

any ideas? thanks!

you can use htmlagilitypack, this:

htmldocument document = new htmldocument(); document.loadhtml(model.contentfield.value); string textvalue = htmlentity.deentitize(document.documentnode.innertext); bool isempty = string.isnullorwhitespace(textvalue); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -