Asp In Head or Body

Discussion in 'ASP General' started by hon123456, Apr 22, 2008.

  1. hon123456

    hon123456 Guest

    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>
    hon123456, Apr 22, 2008
    #1
    1. Advertising

  2. "hon123456" <> wrote in message
    news:...
    > 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.

    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Apr 22, 2008
    #2
    1. Advertising

  3. 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 <Head>
    >> </Head> Tag and Placing code inside <body></body> tag...

    >
    > 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.



    --
    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.
    Dave Anderson, Apr 23, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian W
    Replies:
    10
    Views:
    764
    Brian W
    Jul 2, 2003
  2. Big D
    Replies:
    2
    Views:
    338
    Jeffrey Tan[MSFT]
    Jan 6, 2004
  3. showme

    PHP and ASP.NET go HEAD to HEAD

    showme, Jul 8, 2004, in forum: ASP .Net
    Replies:
    13
    Views:
    724
    Sherif ElMetainy
    Jul 10, 2004
  4. Karl
    Replies:
    0
    Views:
    394
  5. Jiho Han

    Write into <HEAD></HEAD> section?

    Jiho Han, Jan 14, 2004, in forum: ASP .Net Building Controls
    Replies:
    6
    Views:
    233
    Sam Fields
    Jan 16, 2004
Loading...

Share This Page