title: ASP.NET: Can you use server tags to embed C# or VB.NET expressions into a Javascript function?
body: <p>I have an enum called SiteTypes that contains several values that are all bound to a dropdown list.  On the client side, I need to check this dropdown to see if the selected value is one of those enum values.  I don't want to hardcode the value of the enum in the script in case it needs to change, so I want to use a server tag to get it directly from the enum itself.  Conecptually, I would like to do this:</p>
  
  <pre><code>function SiteIdChanged() {
      var x = "&lt;%=SiteTypes.Employee %&gt;";
  }
  </code></pre>
  
  <p>The way I am doing it now is created a protected property in the codebehind that returns that specific enum value and am doing this:</p>
  
  <pre><code>function SiteIdChanged() {
      var x = "&lt;%=EmployeeSiteTypeValue %&gt;";
  }
  </code></pre>
  
  <p>I don't like that, though, because I have to create a special property on every page that I need to do such a check.</p>
  
  <p>Is there a way to do what I want here?</p>