Friday, 1 May 2009

HtmlTextWriter breaks lines

Not exactly sure if this is my fault but I was seeing real strange HTML generated broken across lines even in the middle of attribute values. The code was generated by a custom control using an HtmltextWriter to write a large <ul> list. There was nothing apparently wrong with the code generation but for some reason, the HtmlTextWriter was breaking the text up into 1024 character lines and inserting line breaks wherever the string was positioned and I'm sure it was breaking things despite IE's forgiving rendering engine. You would at least expect the writer to recognise tags and break it there but oh no.
In the end I made sure there were line breaks in the string already before writing to the HtmlTextWriter and it seemed happy with that.
Post a Comment