Marius Vasile

Marius Vasile

  • 589
  • 1.9k
  • 148.5k

asp.net core display bootstrap tabs dynamically in razor pages

Feb 11 2021 6:02 PM
I am trying to put related info in tabs for better view but it will show all data in both tabs. I used example here
https://www.c-sharpcorner.com/blogs/bootstrap-tab-strip-in-asp-net-mvc
 
  1. <div class="container">  
  2.     @if (Model.WOMainsL.Count() > 0)  
  3.     {  
  4.         <div class="row no-gutters">  
  5.             <div class="col-md-2">  
  6.                 <label class="form-control text-white pl-2" style="background-color:firebrick;">WO NUmber</label>  
  7.             </div>  
  8.             <div class="col-md-4">  
  9.                 <span class="form-control text-center btn-link">@Html.DisplayFor(model => model.WONumber)</span>  
  10.             </div>  
  11.         </div>  
  12.         <hr />  
  13.         <div class="row no-gutters mb-4 pl-2">  
  14.             <p class="h6">Subsequent</p>  
  15.         </div>  
  16.         <ul class="nav nav-tabs" role="tablist">  
  17.             @{int i = 0;  
  18.                 foreach (var item in Model.WOMainsL)  
  19.                 {  
  20.                     if (i == 0)  
  21.                     {  
  22.                         <li class="nav-item">  
  23.                             <a class="nav-link active" data-toggle="tab" href="#@item.WOMainID">@item.WONumber - @item.WONumberS</a>  
  24.                         </li>  
  25.                     }  
  26.                     else  
  27.                     {  
  28.                         <li class="nav-item">  
  29.                             <a class="nav-link" data-toggle="tab" href="#@item.WOMainID">@item.WONumber - @item.WONumberS</a>  
  30.                         </li>  
  31.                     }  
  32.                     i++;  
  33.                 }  
  34.             }  
  35.         </ul>  
  36.         <div class="tab-content">  
  37.             @foreach (var item in Model.WOMainsL)  
  38.             {  
  39.                 <div id="@item.WOMainID" class="container tab-pane active">  
  40.                     <br>  
  41.                     <div class="row no-gutters">  
  42.                         <div class="col-md-2 ml-1">  
  43.                             <label class="form-control text-white pl-2" style="background-color:firebrick;">CreateDate</label>  
  44.                             <span class="form-control text-center">@Html.DisplayFor(modelItem => item.CreateDate)</span>  
  45.                         </div>  
  46.                         <div class="col-md-3 ml-1">  
  47.                             <label class="form-control text-white pl-2" style="background-color:firebrick;">WO Status</label>  
  48.                             <span class="form-control text-center">@Html.DisplayFor(modelItem => item.WOStatus)</span>  
  49.                         </div>  
  50.                     </div>  
  51.   
  52.                 </div>  
  53.             }  
  54.         </div>  
  55.     }  
  56. </div>  
Is there anything I should do better? 
 
 

Answers (9)