Master Page and Javascript

Hi,

I am new to ASP.net.
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?

Thanks!
Zeeshan

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
[highlight=C#]
Page.RegisterClientScript(…)



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

Master Page
[highlight=C#]
public function RegisterScriptFile(string filename)
{
  Page.RegisterClientScript(...);
}

Then from your home.aspx
[highlight=C#]
protected void Page_Load(object sender, EventArgs e)
{
((MasterPage)Master).RegisterScriptFile(“home.js”);
}