Asp In Head or Body

Asp In Head or Body

am 22.04.2008 05:30:10 von 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> Tag and Placing code inside tag. Just as
follows:

1. Placing code in the Begining of asp file

<% Response.write "Hello" %>

....
....


2. Placing code in the Head

<% Response.write "Hello" %>
....


3. Placing code in Body

.....
<% Response.write "Hello" %>

Re: Asp In Head or Body

am 22.04.2008 08:14:44 von Anthony Jones

"hon123456" wrote in message
news:beba18ce-1d24-4754-a58f-259507a8d2f2@y18g2000pre.google groups.com...
> 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> Tag and Placing code inside tag. Just as
> follows:
>
> 1. Placing code in the Begining of asp file
>
> <% Response.write "Hello" %>
>
> ....
> ....
>
>
> 2. Placing code in the Head
>
> <% Response.write "Hello" %>
> ....
>
>
> 3. Placing code in Body
>
> .....
> <% Response.write "Hello" %>
>

From ASP's perspective or 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.

--
Anthony Jones - MVP ASP/ASP.NET

Re: Asp In Head or Body

am 23.04.2008 18:16:43 von Dave Anderson

Anthony Jones wrote:
>> I want to know the difference and effect of placing ASP Code
>> in the begining of .asp File and placing code inside
>> Tag and Placing code inside tag...
>
> From ASP's perspective or 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.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.