assign value to javascript variable In C# CodeBehind
<p>How can i assign value to javasctipt variable from code-behind (C#)?</p>

<pre><code>&lt;script type="text/javascript"&gt;
String.prototype.trim = function () { return this.replace(/^\s+|\s+$/, ''); };
function ConstantByCode(_Obj, _Div) {
    var pl = new SOAPClientParameters();
    _Obj.value = _Obj.value.trim();
    pl.add("Code", _Obj.value);
    pl.add("Group", _Obj.Grp);
    alert(_Obj.Grp);
    var _Value = SOAPClient.invoke("ConstantWS.asmx", "GetConstantByCode", pl, false, CallBackEvent);
    if (_Value == null || _Obj.value == "" || _Obj.value == null || IsNumeric(_Obj.value) == false) {
        _Obj.value = "";
        _Div.innerHTML = "";
    }
    else {
        _Div.innerHTML = _Value;
    }
}


function CallBackEvent(r) {

}
function IsNumeric(input) {
    return (input - 0) == input &amp;&amp; input.length &gt; 0;
}
</code></pre>

<p></p>

<p>BehindCode</p>

<pre><code> txtCode.Attributes.Add("Grp", Me.ConstValue)
    txtCode.Attributes.Add("onchange", "ConstantByCode(this," &amp; DivTitle.ClientID &amp; ");")
    txtCode.Attributes.Add("onkeyup", "ConstantByCode(this," &amp; DivTitle.ClientID &amp; ");")
</code></pre>

<p>_obj.Grp has now value.
alert said : undefined</p>
