title: C# variable passed as argument to onclick() is undefined
body: <p>I have a view <code>Details</code> which consists of a partial view <code>_Tabs</code> and a second partial view <code>_Contents</code>. </p>
  
  <p>In one of the partial views (<code>_Tabs</code>), I have a image link, and in the <code>onclick</code> function, I'm passing a variable <code>CatID</code>. 
  This variable contains the value of a property of the ViewModel of the partial view (called <code>TabsForItemViewModel</code>). </p>
  
  <p>When debugging, when the image is clicked, VS displays:</p>
  
  <blockquote>
    <p>Microsoft JScript runtime error: 'CatID' is undefined</p>
  </blockquote>
  
  <p><strong>Partial View "_Tabs":</strong></p>
  
  <p>View Model for the partial view <code>_Tabs</code> is <code>TabsForItemViewModel</code></p>
  
  <pre><code>@model TabsForItemViewModel
  @{
     int CatID = Model.CategoryInfo.CatID; 
   }
  
  &lt;ul&gt;
  &lt;li&gt;
     &lt;a href="#GoToCatLevel"&gt;
       &lt;img border="0" src="view_cat.png" alt ="Up" title="Go To This Category" 
            width="10" height="10" onclick="LoadCategoryData(CatID, this.href)" /&gt;
     &lt;/a&gt;
  &lt;/li&gt;
  ...
  </code></pre>
  
  <p><strong>View "Details":</strong></p>
  
  <pre><code>@model ItemDetailsViewModel
  @{    
      ViewBag.Title = "Item Details";
  }
  
  &lt;div id="Main"&gt;
  ...
     CategoryInfoViewModel categoryData = new CategoryInfoViewModel(itemD.Ca_ID);                                                   
  
      TabsForItemViewModel tabsForItem = new TabsForItemViewModel(categoryData);
      &lt;div id="Tabs" class="div-tab"&gt;                      
          @{Html.RenderPartial("~/Views/Item/_Tabs.cshtml", tabsForItem );}
      &lt;/div&gt;
      ...
  &lt;/div&gt;
  </code></pre>