Add scripts to head dynamically

Many times when i develop a user control i have the need to add some javascript to the header of the page. But the header doesn't have a method where you can add script and RegisterStartupScript inserts the script at the bottom of the page.

So i thought let's create an extension method...

This is how this method can be used for inserting javascript tags to a page's header...

Without the script tags....

And not only javascript but custom css files, meta tags etc...

That's it! Javascript, css files, meta tags and anything else can be inserted to the header dynamically!!

Enjoy...

 

kick it on DotNetKicks.com

14 Comments

Comments have been disabled for this content.