Featured Apps

MyMemes

Create Your Own Memes
Add captions to the most popular meme images or your own photos

Sleepify

Music Alarm Clock
Simple, stylist and intuitive music alarm clock

Collaged

Create Photo Collages
Easily create photo collages to share with friends and family

Dynamically Include Javascript File From C#

15 April 2012

This is really simple and only requires one line of code to include a javscript file dynamically from the C# code behind page.

Copy and paste the line below and change the text to reference your javascript file.

The "Name" is there to avoid the same javascript file being added multiple times.
C#
        Page.ClientScript.RegisterClientScriptInclude("Name", 
            VirtualPathUtility.ToAbsolute("~/Path/To/File.js"));