Ask a Question related to ASP.NET General, Design and Development.
-
threecrans #1
Remove Whitespace when rendering Server Control
If you create a new server control, and override the Render method with the
following code:
protected override void Render(HtmlTextWriter output)
{
// <TABLE id="mytable">
output.AddAttribute(HtmlTextWriterAttribute.Id, "mytable");
output.RenderBeginTag(HtmlTextWriterTag.Table);
// <TR>
output.RenderBeginTag(HtmlTextWriterTag.Tr);
// <TD>
output.RenderBeginTag(HtmlTextWriterTag.Td);
// </TD>
output.RenderEndTag();
// </TR>
output.RenderEndTag();
// </TABLE>
output.RenderEndTag();
}
It produces the following code:
<table id="mytable">
<tr>
<td></td>
</tr>
</table>
But, due to a rendering bug in IE, I need it to be rendered without tabs or
line breaks like so:
<table id="mytable"><tr><td></td></tr></table>
First, just let me say I know I can use the HtmlTextWriter.Write method to
do this, but I need to use the built-in enumerations
(HtmlTextWriterAttribute, HtmlTextWriterStyle, HtmlTextWriterTag) as
demonstrated above.
Here is what I've tried:
- Setting HtmlTextWriter.Indent = 0. No effect.
- Setting HtmlTextWriter.NewLine = "" (or anything). No effect.
- Reinitializing the HtmlTextWriter like so: output = new
HtmlTextWriter(output, ""). This got rid of the tabs.
- Deriving from HtmlTextWriter to try to access the output stream in my
derived class and "strip" whitespace. Overrode the RenderBeforeTag,
RenderAfterTag, NewLine, CoreNewLine members. Didn't work. I probably
didn't follow this idea far enough. May be some merit here.
So, is there any possible way to use the HtmlTextWriter enumerations to
render HTML without tabs and line breaks? I am beginning to get worried that
MS did not consider my dilemma in their design (although they would have to
be immensely stupid to not account for their OWN IE rendering bug when
creating the HtmlTextWriter class). Please help!
threecrans Guest
-
ASP.NET 2 user control rendering
I'm developing a user control like a calendar that displays, for each day, a set of information: the day of the month, if the day is an holiday then... -
Custom Control rendering
I'm overriding the Render method in a Custom Control that inherits from WebControl. Some of the ouput code is as follows; protected override void... -
Composite control not rendering
I have a composite control that for some reason doesn't get executed when a load the page containing it. This is a strange problem because I'm not... -
rendering derived control from composite control
I am triing to load a control derived from a datagrid into a composite control so I can wrap some html around the datagrid. it renders the html in... -
Ignore or remove whitespace in a string
Which is the simplest way to remove all whitespace from a string? Is there a simpler method than a regex replace? Or how can I tell a regex pattern...



Reply With Quote

