Search code examples
.nethtmlxslttextarea

Using XSLT to output an empty HTML textarea element


When attempting to output an empty textarea element, the .NET XSLT processor collapses the element to its short form. Instead of this:

<textarea id="blah" name="blah"></textarea>

I get this:

<textarea id="blah" name="blah"/>

Which causes many web browsers (including IE and Firefox) to render the rest of the page as if it were the contents of the textarea. This sucks.

I can force the XSLT processor to output both the opening and closing textarea tags if I place something in between like a non-breaking space. But that means I have to do more parsing and validation on the client side to tell when the textarea is "truly" empty. I also have to use JavaScript to remove the extra space so that users don't begin their comments with a blank space.

Does anyone know of a way to force the XSLT processor to render both the opening and closing tags without having to insert dummy content?


Solution

  • Find your answer via a similar question right here on Stackoverflow.com :-)

    Here is further explanation from MSDN.