Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making c# Asp.Net 1.1/2 Output decent html

Status
Not open for further replies.

bobbigmac

Programmer
Jun 2, 2005
8
0
0
GB
Hi All

Does anyone know how I can make my asp.net app output html code that doesn't look crappy when I'm generating it all with my code-behind?
Even something simple like having it put \n linebreaks in or something, just so 90% of my page code isn't on 1 bloody line
??
<-- desperately hoping in manchester :D


THanks.
Bob
 
Well, it depends how you're generating it.

As far as web browsers are concerned it doesn't actually matter what the HTML code looks like as long as it's valid so I assume you want to be able to analyse it, in which case you can just copy it, create a new HTML file in Visual Studio, paste it, then choose Edit/Advanced/Format Document. VS will then lay it all out nicely for you.

Nelviticus
 
Heya, thanks both.

I've been using HTML Tidy and the tidy function in visual studio for quite a while.

It's not so much that it's a problem that it renders everything on one line, I just think it doesn't look nice.

I know it's kind of picky, but I've always prided myself on producing not only code that functions well, but that LOOKS neat and readable as well.

Anyone else have any suggestions? I'm thinking there must be an object in the framework somewhere that can override something or other to get a half-decent output code. If you know what I mean :D
 
human readable code is definately worthy goal. so the server code, and even the aspx mark up should be readable by developers. I would argue that once it renders it no longer needs to be human readable in raw form, just renderable. if a user needs to see the raw html there are plenty of tools out there to do so.

there is also a preformance hit to transmitting
Code:
if(true)
{
   return this;
}
else
{ 
   return that;
}
instead of
Code:
if(true){return this;} return that;
granted this example is enlidgable, but on a larger scale extra spaces and line breaks add up.

some servers also provide http compression tools which strip out unecessary charaters and compress the btyes before sending to the client. in this case it occurs after asp.net has sent the response.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top