Asp In Head or Body

H

hon123456

Dear all,

I want to know the difference and effect of placing ASP
Code in the begining of .asp File and placing code inside <Head> </
Head> Tag and Placing code inside <body></body> tag. Just as
follows:

1. Placing code in the Begining of asp file

<% Response.write "Hello" %>

<head>....</head>
<body>....</Body>


2. Placing code in the Head

<head> <% Response.write "Hello" %> </head>
<body>....</Body>


3. Placing code in Body

<head>.....</head>
<body> <% Response.write "Hello" %> </body>
 
A

Anthony Jones

hon123456 said:
Dear all,

I want to know the difference and effect of placing ASP
Code in the begining of .asp File and placing code inside <Head> </
Head> Tag and Placing code inside <body></body> tag. Just as
follows:

1. Placing code in the Begining of asp file

<% Response.write "Hello" %>

<head>....</head>
<body>....</Body>


2. Placing code in the Head

<head> <% Response.write "Hello" %> </head>
<body>....</Body>


3. Placing code in Body

<head>.....</head>
<body> <% Response.write "Hello" %> </body>

From ASP's perspective <head> or <body> have no meaning, they are simply
chunks of literal strings that need to be sent to the client. These tags
only have meaning to browser client that is able to a parse HTML.

When outputting HTML whether ASP code that generates content should be in
the head, the body or anywhere else depends on where the content belongs.

For example you would not place code that dynamically outputs HTML table in
the head neither would you place code that dynamically generates meta tags
in the body.
 
D

Dave Anderson

Anthony said:
From ASP's perspective <head> or <body> have no meaning, they
are simply chunks of literal strings that need to be sent to
the client. These tags only have meaning to browser client
that is able to a parse HTML...

While it is true that the ASP parser does not care a whit about the text of
the Response stream, it should be noted that there is at least one
circumstance under which it is imperative that the server-side processing
precede any output.

If the script reaches the decision to send a Response.Redirect(), for
example, the body of the response must be empty. This has been transparent
to most ASP programmers, as buffering has defaulted to [True] since IIS 5.
But in the odd case that buffering is disabled, any Response.Redirect() call
must precede any output to the response body.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top