title: ASP.NET Display money in Designer properly formatted
body: <p>In code behind I have property which looks like this:</p>
  
  <pre><code>private decimal _myCodeBehindVariable;
  public decimal myCodeBehindVariable
  {
      get { return _myCodeBehindVariable; }
      set { _myCodeBehindVariable = value; }
  }
  </code></pre>
  
  <p>In designer I am getting a value of this variable like this:</p>
  
  <pre><code>&lt;%=myCodeBehindVariable%&gt;
  </code></pre>
  
  <p>However I need to property format it with $ and . so it will look something like this: $35.99</p>
  
  <p>Planning to use accounting.js for this (<a href="http://josscrowcroft.github.io/accounting.js/" rel="nofollow">http://josscrowcroft.github.io/accounting.js/</a>) and I can do this to display the amount in an asp label</p>
  
  <pre><code>&lt;asp:Label ID="Label1" runat="server"&gt;&lt;%=myCodeBehindVariable%&gt;&lt;/asp:Label&gt;
  </code></pre>
  
  <p>The thing is how do I apply js I need something like   </p>
  
  <pre><code>accounting.formatMoney(&lt;%=myCodeBehindVariable%&gt;); &lt;- this does not work!
  </code></pre>
  
  <p>I decided to go with formatting money with code behind and displaying in it. Changed my code to this:</p>
  
  <pre><code>    private string _myCodeBehindVariable;
      public string myCodeBehindVariable
      {
          get { return _myCodeBehindVariable; }
          set { _myCodeBehindVariable = value; }
      }
  </code></pre>
  
  <p>Later in the code ...
              decimal theAmount = -9999.77m;</p>
  
  <pre><code>        myCodeBehindVariable = theAmount.ToString("C2", CultureInfo.CreateSpecificCulture("en-US"));
  </code></pre>
  
  <p>This way I get to keep &lt;%=myCodeBehindVariable%> in designer.</p>