title: Importing javascript into c# class
body: <p>I created a class in C# (Class1.cs) that uses javascript to execute some commands (JavaScript1.js).
  I know that if I import this javascript into the WebForm1.ASPX (the one that uses Class1.cs), it will work.
  The problem is that I want to be able to use this Class1.cs class in other WebForms. To do that, I have to import this javascript into every WebForm.
  Is there a way to import it into the class?</p>
  
  <p>Here is an example:</p>
  
  <p>MAIN PAGE</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %&gt;
  &lt;%@ Import Namespace="WebApplication1"%&gt;
  
  &lt;script runat="server"&gt;
      protected void Test(object sender, EventArgs e)
      {
          Class1 class1 = new Class1();
          class1.callSomething();
      }
  &lt;/script&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script src="JavaScript1.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:Button ID="Button1" runat="server" OnClick="Test" Text ="ALERT"/&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>CLASS</p>
  
  <pre><code>using System;
  
  namespace WebApplication1
  {
      public class Class1
      {
          public void callSomething()
          {
              // Here I call the javascript.
          }
      }
  }
  </code></pre>
  
  <p>JAVASCRIPT</p>
  
  <pre><code>function alertTest()
  {
      alert('worked');
  }
  </code></pre>
  
  <p>In this case I´m using:</p>
  
  <pre><code>&lt;script src="JavaScript1.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But this way, I´ll have to put this in every single webform. What I want to do is import at the class (Class1).</p>
  
  <p>Thanks in advance.</p>