Using C#/VB.NET values in Javascript
<p>I have searched for a definitive answer to my question and not been able to find one.  Lots a site cover the topic but I cannot find the answer I am looking for.</p>

<p>I have an ASPX page that, for example, processes customer queries.  In the code behind I have a Customer class. If I want to use, for example, the customer ID and Name in a JavaScript function.  What is the best way for me to do it?</p>

<p>I have this code (a website I have been asked to update) but I try to sort out all warnings VS displays and this code displays two.</p>

<pre><code>&lt;script type="text/javascript"&gt;
function DoSomeThingFunction(enable)
{
    var enableStr = enable ? "on" : "off";
    var intClientID = &lt;%= Customer.ClientID %&gt;;
    var strClientName = &lt;%= Customer.ClientName %&gt;;

    &lt;!--
        More functionality
    --&gt;

};
&lt;/script&gt;
</code></pre>

<p>Expected expression on the following two lines..</p>

<pre><code>var intClientID = &lt;%= Customer.ClientID %&gt;;
var strClientName = &lt;%= Customer.ClientName %&gt;;
</code></pre>

<p>I can update this code to stop the warnings..</p>

<pre><code>&lt;script type="text/javascript"&gt;
function DoSomeThingFunction(enable)
{
    var enableStr = enable ? "on" : "off";
    var intClientID = parseInt('&lt;%= Customer.ClientID %&gt;');
    var strClientName = '&lt;%= Customer.ClientName %&gt;';

    &lt;!--
        More functionality
    --&gt;

};
&lt;/script&gt;
</code></pre>

<p>My question is:  What is the best method of achieving this without getting any kind of warning?  Does the best method mean I will get a warning and therefore have to put up with it?  I hate to see warnings of any kind and try to fix them all.</p>

<p>Thanks for looking</p>
