Best way to modify HTML HEAD from web control

D

darrel

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
 
A

AndrewF

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
 
D

darrel

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
 
B

Bruce Barker

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

-- bruce (sqlwork.com)
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top