title: Share constants between C# and Javascript in MVC Razor
body: <p>I'd like to use string constants on both sides, in C# on server and in Javascript on client.
  I encapsulate my constants in C# class</p>
  
  <pre><code>namespace MyModel
  {
          public static class Constants
          {
              public const string T_URL = "url";
              public const string T_TEXT = "text";
       . . .
          }
  }
  </code></pre>
  
  <p>I found a way to use these constants in Javascript using Razor syntax, but it looks weird to me:</p>
  
  <pre><code>@using MyModel
          &lt;script type="text/javascript"&gt;
  
              var T_URL = '@Constants.T_URL';  
              var T_TEXT = '@Constants.T_TEXT';
       . . .
              var selValue = $('select#idTagType').val();
              if (selValue == T_TEXT) { ... 
  </code></pre>
  
  <p>Is there any more "elegant" way of sharing constants between C# and Javascript?
  (Or at least more automatic, so I do not have to make changes in two files)</p>