471,344 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 software developers and data experts.

asp.net remove white space in html

is there a way to remove all white spaces in the html output? ie. everything
as one line.
Jul 21 '05 #1
3 7990
Aaron wrote:
is there a way to remove all white spaces in the html output? ie. everything
as one line.


Well, Response.Filter is where I'd start:

http://msdn.microsoft.com/library/de...ilterTopic.asp

But I don't know eliminating all whitespace is what you'd do, cuz you'd
have to figure out how to detect if you were inside of a tag (don't want
to just erase all spaces, etc.). You wouldn't strip out whitespace like
that.

But you could strip out things like Tab characters (if this is what you
meant). crlf's I thought were problematic when I tried it for a client
(for their pages), but I can't think of why (I thought it caused
problems in Javascript. As long as every line ends with ; the JS should
still run fine. Unless you use the <!-- // --> wrapper around
scripts, as I don't think this can go all on the same line. Example:

<script language="javascript">
<!--
alert('hello');
// -->
</script>

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Jul 21 '05 #2
I think the following link is useful.

http://www.codeproject.com/aspnet/WhitespaceFilter.asp

"Aaron" wrote:
is there a way to remove all white spaces in the html output? ie. everything
as one line.

Jul 21 '05 #3
It sounds like he only wants to filter out line breaks, for whatever reason.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:Ok**************@TK2MSFTNGP10.phx.gbl...
Aaron wrote:
is there a way to remove all white spaces in the html output? ie.
everything as one line.


Well, Response.Filter is where I'd start:

http://msdn.microsoft.com/library/de...ilterTopic.asp

But I don't know eliminating all whitespace is what you'd do, cuz you'd
have to figure out how to detect if you were inside of a tag (don't want
to just erase all spaces, etc.). You wouldn't strip out whitespace like
that.

But you could strip out things like Tab characters (if this is what you
meant). crlf's I thought were problematic when I tried it for a client
(for their pages), but I can't think of why (I thought it caused problems
in Javascript. As long as every line ends with ; the JS should still run
fine. Unless you use the <!-- // --> wrapper around scripts, as I don't
think this can go all on the same line. Example:

<script language="javascript">
<!--
alert('hello');
// -->
</script>

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

45 posts views Thread by Stephen Poley | last post: by
reply views Thread by Mark Moore | last post: by
5 posts views Thread by Michael Shell | last post: by
38 posts views Thread by Xah Lee | last post: by
4 posts views Thread by Aaron | last post: by
4 posts views Thread by Andreas Prilop | last post: by
5 posts views Thread by Richard Maher | last post: by
reply views Thread by Ronak mishra | last post: by

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.