Master Page and Javascript


I am new to
My questions is regarding using Javascript and CSS files in Master Page.

Suppose I have two pages home.aspx and contact.aspx. Home page uses home.js and contact page requires contact.js. How should I load ONLY home.js file at home page and contact.js file at contact.aspx page in Master file?


The typical way I have approached this in the past is to have the pages themselves add the script in their code behind.

Example: home.aspx

If you need it to be in the head or within the master page itself, then something like this usually works

Master Page
public function RegisterScriptFile(string filename)

Then from your home.aspx
protected void Page_Load(object sender, EventArgs e)