I created ASP.NET user control with javascript function :
<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"TestControl.ascx.cs\" Inherits
I found a solution in another site which allows you to use external file
if (!Page.ClientScript.IsClientScriptIncludeRegistered("key")) { string url = ResolveClientUrl("~/Scripts/file.js"); Page.ClientScript.RegisterClientScriptInclude("key", url); }