Jump to content

asp and formatting


mfarrell

Recommended Posts

It is doing exactly what you told it to do. ASP has a single purpose, other than whatever work is done on the server: to return content to the browser. If your ASP code is returning HTML content that is not formatted very well, then it's not going to look very well in the browser. If you're talking about things in the ASP code like spaces or line breaks and expecting those to go to the browser, that is not how ASP works. It will only send to the browser specifically what you tell it to send. For example, if you have this code:

<body><%response.write("Hello World!")%><%fname=Request.form("fname")lname=Request.form("lname")response.write("<p>Hello " & fname & " " & lname & "!</p>")response.write("<p>Welcome to my Web site!</p>")%></body>
And, assuming the fname input is "Foo", and the lname input is "Bar", the result of that code will send this to the browser:
<body>Hello World!<p>Hello Foo Bar!</p><p>Welcome to my Web site!</p></body>
Notice, for example, that the <p> elements do not have any space between them, because there is no ASP code telling it to send a space to the browser (even though those ASP lines are on different lines). Each Response.Write line is telling it specifically what to send to the browser. Anything outside of an ASP block (<%...%>) is also output that will directly go to the browser, it doesn't even get processed by ASP.As far as the browser is concerned, the browser does not know nor care anything about ASP. It does not know that ASP was involved in any way in creating the page, it doesn't understand nor read the language, none of that. Just like sending a request for a static HTML page, all the browser knows is that it sent a request to the server, and it got a response. The browser expects that response to be HTML content. If your ASP code is sending crap HTML content to the browser, then the browser is going to show crap HTML content. The reason why you ran the code that I posted and it printed each thing on a different line was because I specifically told ASP to send the HTML <br> tag to tell the browser that it's a new line.This is the bottom line: the HTML that is sent by ASP, and the HTML from any static HTML file that you save with Notepad, is completely indistinguishable to the browser. The browser only sees HTML code. So if your ASP pages are showing up looking messed up in the browser, it's because the content that you are sending to the browser is messed up. You can always pull up an ASP page in your browser and go to View Source to see the content that the browser received from the server.
Link to comment
Share on other sites

so my question is this WHY do all of the examples posted on the internet show the 'results' as being properly formatted html?

 

when clearly they do not work that way, when copied and pasted into a new blank document the results in no way match what is being shown as an example?

 

it can not be 'my crap' html that is at fault; when I copy directly from a page that shows one thing, and produces an entirely different result.

Link to comment
Share on other sites

OK, I think I have it worked out....my 'form' request for user input can go on a HTML page....

 

The response is fed to an ASP page...that needs formatting on the back end due to ASP not caring about 'whitespace'

Edited by mfarrell
Link to comment
Share on other sites

so my question is this WHY do all of the examples posted on the internet show the 'results' as being properly formatted html?when clearly they do not work that way, when copied and pasted into a new blank document the results in no way match what is being shown as an example?

You're welcome to point to a specific example where the output produced does not match what the example shows. Maybe the examples are poorly written, maybe you're not doing something correctly, I don't know. I'm not sitting there watching what you're doing.
Link to comment
Share on other sites

The response is fed to an ASP page...that needs formatting on the back end due to ASP not caring about 'whitespace'

 

Sounds like ordinary HTML. The following two paragraphs will look identical...

<p>My         dog        is       dead.</p><p>My dog is dead.</p>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...