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> </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
Post a Comment