Need to pass a C# string to a javascript function
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3553680/how-do-you-pass-variables-from-c-sharp-to-javascript">How do you pass variables from c# to javascript?</a>  </p>
</blockquote>



<p>I have a C# method that validates the user credentials during Login. </p>

<pre><code>public string CreateLoginjson(string strErrorType, bool blIsAuthenticated)
{
    StringBuilder sbLoginJson = new StringBuilder();
    if (blIsAuthenticated)
    {
        sbLoginJson.Append("{LoginSuccess:1");
    }
    else
    {
        sbLoginJson.Append("{LoginSuccess:0");
    }

    if (strErrorType != string.Empty)
    {
        if (strErrorType.TrimEnd(new char[] { ',' }) == "Token")
        {
            sbLoginJson.Append(",txtTestTokenNumber1:\"Error\"");
            sbLoginJson.Append(",txtTestTokenNumber2:\"Error\"");
            sbLoginJson.Append(",txtTestTokenNumber3:\"Error\"");
            sbLoginJson.Append(",txtTestTokenNumber4:\"Error\"");

        }
        else if (strErrorType.TrimEnd(new char[] { ',' }) == "Password")
        {
            sbLoginJson.Append(",txtPassword:\"Error\"");

        }
        else if (strErrorType.TrimEnd(new char[] { ',' }) == "UserName")
        {
            sbLoginJson.Append(",UserName:\"Error\"");

        }

    }
    sbLoginJson.Append("}");

    return sbLoginJson.ToString();


}
</code></pre>

<p>I now have to pass the string sbLoginJson to a Javascript function, which checks if the user has failed to provide the login details.</p>

<p>Java Script Function, that I have written so far.</p>

<pre><code>function GetLoginJson(strLoginJson) {
    if (strLoginJson != "" &amp;&amp; strLoginJson != undefined) {
        var objLoginJson = eval('"+strLoginJson+"');
    }
    if(objLoginJson.sbLoginJson())
    {

    }
    else
    {

    }
}
</code></pre>

<p>Can someone please tell me how to pass the string &amp; make it work?  Thanks in advance</p>
