You'll want to use the Page.ClientScript manager.
The following code will only register your code once per a page.
if (!page.ClientScript.IsClientScriptBlockRegistered(tType, "MyScript"))
{
page.ClientScript.RegisterClientScriptBlock(tType, "MyScript", sScript);
}
You can also make sure that *.js files get added only once
if (!page.ClientScript.IsClientScriptIncludeRegistered(tType, "MyScriptFile"))
{
page.ClientScript.RegisterClientScriptInclude(tType,"MyScriptFile","MyJavaScript.js")
}