title: .Net Core - Putting views into a tabs
body: <p>I'm creating a web page using .Net Core and I have a pretty complex program as of now. I have two different models (Customer and User) with different properties and they each have a controller and a view.</p>
  
  <p>I want to put these two views/controllers together in a tab view, so that under the Customer tab the customer index is shown and under the User tab the user index is show. I want it to be similar to what the following generates:</p>
  
  <pre><code>&lt;div&gt;
      &lt;ul class="nav nav-tabs" role="tablist"&gt;
          &lt;li role="presentation" class="active"&gt;
              &lt;a href="#first" aria-controls="first" role="tab" data-toggle="tab"&gt;First&lt;/a&gt;
          &lt;/li&gt;
          &lt;li role="presentation"&gt;
              &lt;a href="#second" aria-controls="second" role="tab" data-toggle="tab"&gt;Second&lt;/a&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  
      &lt;div class="tab-content"&gt;
          &lt;div role="tabpanel" class="tab-pane active" id="first"&gt;
              Customer
          &lt;/div&gt;
          &lt;div role="tabpanel" class="tab-pane" id="second"&gt;
              User
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qdkJp.png" rel="nofollow"><img src="https://i.stack.imgur.com/qdkJp.png" alt="Tab View"></a></p>
  
  <p>Is this possible in .Net Core?</p>
  
  <h1>EDIT1:</h1>
  
  <p>I am aware of how to use partial views and I was thinking this might be the way, however I am not an expert on how to use these. I just used them to restructure the way the details page for my models were shown. However as I have already implemented two complete controllers and their corresponding views I was wondering if there is an easier way?</p>
  
  <p>Could I create a viewModel (containing a list of customers and users) and use that to display either? (I am using a PaginatedList on both views to order and limit the amount of items shown on the pages.). In the controller below I try to get the customers and users from the DB and pass them to the viewModel which is then passed to the View. Is this how it can be done in .Net Core? (Problem can be found in commented code in controller).</p>
  
  <h1>Model</h1>
  
  <pre><code>public class CustomerUserViewModel
  {
      public PaginatedList&lt;Customer&gt; Customers { get; set; }
      public PaginatedList&lt;User&gt; Users { get; set; }
  
      //OR
  
      public List&lt;Customer&gt; Customers { get; set; }
      public List&lt;User&gt; Users { get; set; }
  }
  </code></pre>
  
  <h1>View</h1>
  
  <pre><code>@model CustomerUserViewModel
  
  &lt;h2&gt;CustomerUserTabbing&lt;/h2&gt;
  &lt;div&gt;
      &lt;ul class="nav nav-tabs" role="tablist"&gt;
          &lt;li role="presentation" class="active"&gt;
              &lt;a href="#first" aria-controls="first" role="tab" data-toggle="tab"&gt;Customer&lt;/a&gt;
          &lt;/li&gt;
          &lt;li role="presentation"&gt;
              &lt;a href="#second" aria-controls="second" role="tab" data-toggle="tab"&gt;User&lt;/a&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  
      &lt;div class="tab-content"&gt;
          &lt;div role="tabpanel" class="tab-pane active" id="first"&gt;
              @Html.Partial("~/Views/Customer/Index.cshtml", Model.Customers)
          &lt;/div&gt;
          &lt;div role="tabpanel" class="tab-pane" id="second"&gt;
              @Html.Partial("~/Views/User/Index.cshtml", Model.Users)
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <h1>Controller</h1>
  
  <pre><code>public IActionResult CustomerUserTabbing()
  {
      //I found that these two lines don't actually return anything
      //See new code below this
      //var userlist = from u in _context.Users select u;
      //var customerlist = from c in _context.Customers select c;
  
      //New Code
      var users = _context.Users
         .Where(u =&gt; u.UserID != 0)
         .OrderBy(u =&gt; u.First_Name)
         .ToList();
      var customers = _context.Customers
         .Where(c =&gt; c.CustomerID != 0)
         .OrderBy(c =&gt; c.Name)
         .ToList();
  
      CustomerUserViewModel viewModel = new CustomerUserViewModel();
      viewModel.Customers = customers; //these two lines gives errors
      viewModel.Users = users; //cannot convert IQueryable to PaginatedList
  
      return View(viewModel);
  }
  </code></pre>
  
  <p>Does anyone know how to solve this?</p>