title: Pass C# variable to JavaScript in ASP webforms
body: <p>I'm using ASP web forms. Suppose I have a variable in my user control (ascx.cs)</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
          {
              public string someText = "Hello World";
          }
  </code></pre>
  
  <p>I want to pass this variable to JavaScript. The code in the ascx file:</p>
  
  <pre><code>&lt;%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %&gt;
  &lt;%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %&gt;
  &lt;%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %&gt;
  &lt;%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %&gt;
  &lt;%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %&gt;
  &lt;%@ Import Namespace="Microsoft.SharePoint" %&gt;
  &lt;%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %&gt;
  &lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CalendarUserControl.ascx.cs" Inherits="Fransabank.Calendar.CalendarUserControl" %&gt;
  
  &lt;script type="text/javascript"&gt;
      console.log(someText);
  &lt;/script&gt;
  </code></pre>
  
  <p>I'm getting in the console window:</p>
  
  <blockquote>
    <p>ReferenceError: someText is not defined</p>
  </blockquote>