0

Would it be possible to set something in asp.net application in such a way that all of carriage return and line feed will be removed in aspx pages?

For example:

if I view source of my page, I see:

<div>
   abc
</div>

I want to have:

<div>abc</div>

Thanks in advance!

olidev
  • 20,058
  • 51
  • 133
  • 197
  • 1
    If you just want to change the formatting of your HTML while you type and/or format you code Cftrl-K-D, you can go into Tools -> Options -> Text Editor -> HTML -> Formatting -> Tag Specific Options and change the way Visual Studio Formats the "div" tag or any other tag you want. As you make changes, look at the preview of the bottom of the window to see what your code will now look like. – Zachary May 11 '11 at 21:58

1 Answers1

0

You have three options depending on why you are doing this.

The first is to run a minifier during the build process; however, this is not recommended for a number of reasons. Key being that those carriage returns might be important to you.

The second is to create an httpmodule that removes them as the html is emitted back to the browser. Again, not recommended for the same reasons as above.

The third option is to simply turn on compression (gzip) for your content. This will compress it down for transfer. When the browser uncompresses it for display the carriage returns will still be there but the compression should have reduced the amount of network traffic involved.

Honestly, I can't think of a reason to do anything other than turn on regular compression. The downsides are too big.

Community
  • 1
  • 1
NotMe
  • 87,343
  • 27
  • 171
  • 245
  • Hi Chris! If you view source of Facebook. It looks like what I want to achieve. all of and are removed. – olidev May 11 '11 at 22:05
  • @JoesyXHN: Then look at http://code.google.com/p/htmlcompressor/ or something similar. The only reason Facebook goes that far is due to the size of their traffic. Very few other sites bother. – NotMe May 11 '11 at 22:25