javascript variable existence on page
<p>I'm creating javascript Variable using c#.net inside code behind page and putting that variable on page using Page.ClientScript.RegisterClientScriptBlock(). So that variable is available on page and I can read(get) that variable value on client side using jquery.</p>

<p>I'm doing following:</p>

<pre><code>C# :

category_columnNames += "var vertical_" + catItem.VerticalID + "_columnNames=['Tools','PersonID','Topic','Category','Cost','Company']";    
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "LoadColumnNames", category_columnNames, true);
</code></pre>

<p>By doing this let's say :<code>var vertical_1_columnNames=['Tools','PersonID','Topic','Category','Cost','Company'];</code> is on page. Now I want to first check if that <code>variable(vertical_1_columnNames)</code> exists on page or not. If yes then I need to get value of it (<code>['Tools','PersonID','Topic','Category','Cost','Company']</code>) on client side.I'm doing following on client side:</p>

<p>Client Side :</p>

<pre><code>function ViewCartDirectLeadsGridInit(gridID) {

     alert(gridID);//vertical_1_CategoryGrid

     var vertical = gridID.toString().split('_')[1];
     var columnNames = "vertical_" + vertical + "_columnNames";

     alert(columnNames); // vertical_1_columnNames
     alert(typeof(columnNames));// string 
     alert(eval(columnNames)); // ['Tools','PersonID','Topic','Category','Cost','Company']

      if (!window.columnNames) // This is not working.I want to check for existence of var vertical_1_columnNames
      {
       alert("success");
       return false;
       }
      else{
      // do something;
      }

 }          
</code></pre>

<p>Any suggestion?</p>

<p>Thanks,</p>

<p>A</p>
