title: Using C# object in razor view page
body: <p>I have this rows of c# code in View razor page:</p>
  
  <pre><code>@{
      List&lt;UserContact&gt; userContacts = ViewBag.contacts;
      String contacts = Html.Partial("~/Views/Shared/Contacts.cshtml", userContacts).ToHtmlString();
  }
  </code></pre>
  
  <p>I want to use the content of contacts variable in JavaScript function since the contacts is a C# object I cant use this variable in JavaScript function.</p>
  
  <p>Is there any way to use contacts variable in Javascript function?
  Maybe since the type is string it can be converted to JavaScript variable?</p>