Write into <HEAD></HEAD> section?

Discussion in 'ASP .Net Building Controls' started by Jiho Han, Jan 14, 2004.

  1. Jiho Han

    Jiho Han Guest

    Is it possible to write into HEAD section, for example to write out a LINK
    tag?
     
    Jiho Han, Jan 14, 2004
    #1
    1. Advertising

  2. hi Jiho,
    try <head id="head1" runat="server"></head>

    delcare head1 as an HtmlControls.HtmlGenericControl
    and then access it from code.


    "Jiho Han" <> wrote in message
    news:...
    > Is it possible to write into HEAD section, for example to write out a LINK
    > tag?
    >
    >
     
    Alessandro Zifiglio, Jan 14, 2004
    #2
    1. Advertising

  3. Hi Jiho,

    Add a runat="server" attribute to the <head> tag, then refer it in your
    codebehind by its ID and you're ready to go... (the IDE will wipe off your
    <head> tag from time to time...)

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx

    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    "Jiho Han" <> wrote in message
    news:...
    > Is it possible to write into HEAD section, for example to write out a LINK
    > tag?
    >
    >
     
    Victor Garcia Aprea [MVP], Jan 14, 2004
    #3
  4. Jiho Han

    Jiho Han Guest

    Thanks guys for your help.

    "Victor Garcia Aprea [MVP]" <> wrote in message
    news:%...
    > Hi Jiho,
    >
    > Add a runat="server" attribute to the <head> tag, then refer it in your
    > codebehind by its ID and you're ready to go... (the IDE will wipe off your
    > <head> tag from time to time...)
    >
    > --
    > Victor Garcia Aprea
    > Microsoft MVP | ASP.NET
    > Looking for insights on ASP.NET? Read my blog:
    > http://obies.com/vga/blog.aspx
    >
    > To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    > "Jiho Han" <> wrote in message
    > news:...
    > > Is it possible to write into HEAD section, for example to write out a

    LINK
    > > tag?
    > >
    > >

    >
    >
     
    Jiho Han, Jan 14, 2004
    #4
  5. Jiho Han

    Sam Fields Guest

    Jiho was looking to write a <link> tag. I've attempted this myself. I can
    successfully write the <link> tag, but it does not work to access the .css
    file and render the styles at design time. Run-time is perfectly fine.

    Any clue how to get a programmatically added <link> tag to successfully
    render the css styles?

    Thanks!
    Sam Fields

    "Victor Garcia Aprea [MVP]" <> wrote in message
    news:%...
    > Hi Jiho,
    >
    > Add a runat="server" attribute to the <head> tag, then refer it in your
    > codebehind by its ID and you're ready to go... (the IDE will wipe off your
    > <head> tag from time to time...)
    >
    > --
    > Victor Garcia Aprea
    > Microsoft MVP | ASP.NET
    > Looking for insights on ASP.NET? Read my blog:
    > http://obies.com/vga/blog.aspx
    >
    > To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    > "Jiho Han" <> wrote in message
    > news:...
    > > Is it possible to write into HEAD section, for example to write out a

    LINK
    > > tag?
    > >
    > >

    >
    >
     
    Sam Fields, Jan 15, 2004
    #5
  6. Jiho Han

    Jiho Han Guest

    Sam,

    I don't know what you mean by your question. Are you trying to have the css
    "rendered" at design-time? I don't know if that's possible. For example, I
    tried to set the bgcolor of the BODY tag but it had no effect on the
    designer window. I would guess that's probably the same behavior you can
    expect with the css at design-time.

    In any case, I decided not to use the LINK in my control. After all, as a
    control developer, I can't control whether the page developer specifies
    runat="server" attribute on the HEAD tag. Instead I have decided to add the
    necessary tags via client script block. RegisterClientScriptBlock method
    works fine for me in this case.

    Thanks all for your help!
    Jiho

    "Sam Fields" <> wrote in message
    news:...
    > Jiho was looking to write a <link> tag. I've attempted this myself. I

    can
    > successfully write the <link> tag, but it does not work to access the .css
    > file and render the styles at design time. Run-time is perfectly fine.
    >
    > Any clue how to get a programmatically added <link> tag to successfully
    > render the css styles?
    >
    > Thanks!
    > Sam Fields
    >
    > "Victor Garcia Aprea [MVP]" <> wrote in message
    > news:%...
    > > Hi Jiho,
    > >
    > > Add a runat="server" attribute to the <head> tag, then refer it in your
    > > codebehind by its ID and you're ready to go... (the IDE will wipe off

    your
    > > <head> tag from time to time...)
    > >
    > > --
    > > Victor Garcia Aprea
    > > Microsoft MVP | ASP.NET
    > > Looking for insights on ASP.NET? Read my blog:
    > > http://obies.com/vga/blog.aspx
    > >
    > > To contact me remove 'NOSPAM'. Please post all questions to the

    newsgroup
    > > "Jiho Han" <> wrote in message
    > > news:...
    > > > Is it possible to write into HEAD section, for example to write out a

    > LINK
    > > > tag?
    > > >
    > > >

    > >
    > >

    >
    >
     
    Jiho Han, Jan 16, 2004
    #6
  7. Jiho Han

    Sam Fields Guest

    It acutally applies all the styles at design-time, but only if the <link>
    tag is added to the top of the aspx page, and not added programmatically.
    For this same reason, I abandoned adding <link> tags in my controls as well.
    Anyway, thanks for your response!

    Sam


    "Jiho Han" <> wrote in message
    news:...
    > Sam,
    >
    > I don't know what you mean by your question. Are you trying to have the

    css
    > "rendered" at design-time? I don't know if that's possible. For example,

    I
    > tried to set the bgcolor of the BODY tag but it had no effect on the
    > designer window. I would guess that's probably the same behavior you can
    > expect with the css at design-time.
    >
    > In any case, I decided not to use the LINK in my control. After all, as a
    > control developer, I can't control whether the page developer specifies
    > runat="server" attribute on the HEAD tag. Instead I have decided to add

    the
    > necessary tags via client script block. RegisterClientScriptBlock method
    > works fine for me in this case.
    >
    > Thanks all for your help!
    > Jiho
    >
    > "Sam Fields" <> wrote in message
    > news:...
    > > Jiho was looking to write a <link> tag. I've attempted this myself. I

    > can
    > > successfully write the <link> tag, but it does not work to access the

    ..css
    > > file and render the styles at design time. Run-time is perfectly fine.
    > >
    > > Any clue how to get a programmatically added <link> tag to successfully
    > > render the css styles?
    > >
    > > Thanks!
    > > Sam Fields
    > >
    > > "Victor Garcia Aprea [MVP]" <> wrote in message
    > > news:%...
    > > > Hi Jiho,
    > > >
    > > > Add a runat="server" attribute to the <head> tag, then refer it in

    your
    > > > codebehind by its ID and you're ready to go... (the IDE will wipe off

    > your
    > > > <head> tag from time to time...)
    > > >
    > > > --
    > > > Victor Garcia Aprea
    > > > Microsoft MVP | ASP.NET
    > > > Looking for insights on ASP.NET? Read my blog:
    > > > http://obies.com/vga/blog.aspx
    > > >
    > > > To contact me remove 'NOSPAM'. Please post all questions to the

    > newsgroup
    > > > "Jiho Han" <> wrote in message
    > > > news:...
    > > > > Is it possible to write into HEAD section, for example to write out

    a
    > > LINK
    > > > > tag?
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Sam Fields, Jan 16, 2004
    #7
    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:
    821
    Brian W
    Jul 2, 2003
  2. Sergey Morkovkin
    Replies:
    5
    Views:
    17,463
    gamcfarlane
    Jul 14, 2009
  3. PJ6
    Replies:
    3
    Views:
    389
    Steve C. Orr [MVP, MCSD]
    Sep 6, 2005
  4. Sergey Morkovkin

    Insert SCRIPT or LINK tag into a HEAD section DYNAMICALLY

    Sergey Morkovkin, Sep 11, 2003, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    217
    Slava Tihonyuk
    Sep 15, 2003
  5. kampy
    Replies:
    9
    Views:
    371
    Steven D'Aprano
    Oct 19, 2012
Loading...

Share This Page