473,761 Members | 10,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(HtmlText Writer output)
{
// <TABLE id="mytable">
output.AddAttri bute(HtmlTextWr iterAttribute.I d, "mytable");
output.RenderBe ginTag(HtmlText WriterTag.Table );

// <TR>
output.RenderBe ginTag(HtmlText WriterTag.Tr);

// <TD>
output.RenderBe ginTag(HtmlText WriterTag.Td);

// </TD>
output.RenderEn dTag();

// </TR>
output.RenderEn dTag();

// </TABLE>
output.RenderEn dTag();
}

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"><t r><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
(HtmlTextWriter Attribute, HtmlTextWriterS tyle, HtmlTextWriterT ag) 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!
Nov 17 '05 #1
0 3350

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
90015
by: Thomas Mlynarczyk | last post by:
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 to ignore all whitespace in my subject string? There is a global modifier to ignore all spaces in the pattern, but I couldn't find one for ignoring spaces in the subject string. Do I really have to either do a preg_replace to remove all whitespace or stick a lot of \s* into my search pattern? ...
5
5290
by: Sue | last post by:
On code-behind page: (attributes set programatically for each of these elements) linkbutton added to tablecell textbox added to tablecell tablecells added to tablerow tablerow added to table (table.ID is TestTable) On .aspx page: <HeaderTemplate> <asp:Table ID="TestTable" runat="Server" /> </HeaderTemplate>
2
4729
by: Mike Speak | last post by:
I have a user control that I want to use to render 4 menu items (retrieved from db) on the top of each of my asp.net pages. The user control defines a table, with one TR and one TD. Within the TD I have a placeholder defined: <asp:PlaceHolder ID="categoriesPlaceHolder" Runat="server" /> In the code behind of the user control, on the Page_Load event I am retrieving data from db and adding controls to the placeholder as
0
2256
by: Shan Plourde | last post by:
Hi everyone, I have been using various regular expressions with the ASP.NET RegularExpressionValidator for quite some time. In general it works very well. One of the common regex's that I use follows: ValidationExpression = "^\d{0,3}(\.\d{0,4})?$" The purpose of this one is to validate that numeric values input follow the syntax 999.9999. This works well. But, one thing that I have never tested previously (which has now been uncovered...
0
1238
by: postings | last post by:
Hi The code below compiles and works. It's a control derived from a drop down list that displays countries for the user to select. My issue is that is I look in the drop down list in Design view of Visual Studio 2005 (final), rather than rendering the dropdownlist, it renders a gray box displaying: "Error Creating Control - ddlCountry, object reference not set to an instance of an object."
10
1676
by: Hermann.Richter | last post by:
Is there any way to remove automatically all blank chars from the html sent to the client?? Example: ---------------------------------------------------------------- <? echo "HTML tags here<br>" ; ?> more HTML here <div>
2
4241
by: Benton | last post by:
Hi there, I'm creating a custom server control, inheriting from TextBox. It has this AsDateTime property that returns the textbox contents converted to the nullable DateTime data type, as follows: public class TextBoxWeb : System.Web.UI.WebControls.TextBox {
15
50258
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
3
5275
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first add the pane the remove event does not get handled, though thereafter it is handled without problems. ==================================================
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.