title: passing variables from cs file to aspx file (to javascript) using visual studio 2012
body: <p>My website is on WPF project.
  I want to pass a string from my cs file:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  public partial class _Default : System.Web.UI.Page
  {
      public string strHello = "Hello World!";
      protected void Page_Load(object sender, EventArgs e)
      {
  
      }
  }
  </code></pre>
  
  <p>To my website:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head id="Head1" runat="server"&gt;
  &lt;script type="text/javascript"&gt;var jsstrHW = '&lt;%=strHW%&gt;'; alert("jsstrHW = " + jsstrHW);&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The output from alert method:</p>
  
  <pre><code>jsstrHW = &lt;%=strHW%&gt;
  </code></pre>
  
  <p>Please guide me how to do it right.
  Thanks a lot,
  Orian.</p>
  
  <p><strong>EDIT:</strong>
  I tried:</p>
  
  <pre><code>ScriptManager.RegisterStartupScript(this, this.GetType(), "someID", "alert('This pops up');", true);
  </code></pre>
  
  <p>and it didn't work as well.
  I copied only my aspx file and his cs file to other folder, then I closed my solution and created new one with those files. Everything worked on Google Chrome! So.. my code is probably right, but something in my solution ruin my website. what can it be? As I said before - I need that website for WPF app and not for Google Chrome (or Mozilla Firefox, etc.).</p>
  
  <p>Thanks again,
  Orian.</p>