Best way to modify HTML HEAD from web control

Discussion in 'ASP .Net' started by darrel, Aug 5, 2005.

  1. darrel

    darrel Guest

    I have a webcontrol for the navigation our site. I'd like to load some
    javascript with it. Normally, one would put these in the HEAD of the parent
    page. Is there a preferred method for adding tags to the HEAD of a parent
    page from a web control?

    In the past, I've simply created a 'header tags' control and any time
    another controls needs to write something in the head, I add that to this
    other control. That doesn't seem to be the best method.

    -Darrel
     
    darrel, Aug 5, 2005
    #1
    1. Advertising

  2. darrel

    AndrewF Guest

    Hi mate,

    use the Page.RegisterClientSideScript(string ID, string Script) method
    and this will take care of it all for you. This way you can specify
    your stuff in a different file or wherever and just pass in the string
    and off you go.

    Cheers
    AndrewF
     
    AndrewF, Aug 5, 2005
    #2
    1. Advertising

  3. darrel

    darrel Guest

    > use the Page.RegisterClientSideScript(string ID, string Script) method
    > and this will take care of it all for you. This way you can specify
    > your stuff in a different file or wherever and just pass in the string
    > and off you go.


    Instead of passing the entire script, can one just pass a link to the .js?

    In otherwords, I don't need to actually put JS in the HEAD, but just the
    SCRIPT tag:

    <script type="text/javascript" src="/myscript.js"></script>

    -Darrel
     
    darrel, Aug 5, 2005
    #3
  4. darrel

    Bruce Barker Guest

    note: RegisterClientSideScript add the script right after the <form>, not
    inside the <head>

    -- bruce (sqlwork.com)


    "AndrewF" <> wrote in message
    news:...
    > Hi mate,
    >
    > use the Page.RegisterClientSideScript(string ID, string Script) method
    > and this will take care of it all for you. This way you can specify
    > your stuff in a different file or wherever and just pass in the string
    > and off you go.
    >
    > Cheers
    > AndrewF
    >
     
    Bruce Barker, Aug 5, 2005
    #4
    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:
    825
    Brian W
    Jul 2, 2003
  2. showme

    PHP and ASP.NET go HEAD to HEAD

    showme, Jul 8, 2004, in forum: ASP .Net
    Replies:
    13
    Views:
    787
    Sherif ElMetainy
    Jul 10, 2004
  3. Karl
    Replies:
    0
    Views:
    437
  4. Jiho Han

    Write into <HEAD></HEAD> section?

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

    Modify Head Tag from Custom Control.

    markbaer, Aug 1, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    138
    markbaer
    Aug 1, 2005
Loading...

Share This Page