c# - A .cshtml mix goes wrong -


i try implement loop displaying small boxes.. following first code has result :

second image

(code) :

<div class="row">     <div class="col-lg-3 col-xs-6">     <!-- small box -->     <!-- achtung hier soll man vielleicht die adresse ändern -->      @{for (int = 0; < model.liststations.length; i++)             {                 string urltemp = model.liststations[i];                 string colortemp = "small-box bg-" + model.listcolors[i % model.listcolors.length];                 system.diagnostics.debug.writeline(colortemp);         <div class= "small-box bg-blue">             <div class="inner">                 <h3>station</h3>                 <p> model.liststations[i]</p>             </div>             <div class="icon">                 <i class="fa fa-heartbeat" aria-hidden="true"></i>             </div>             <a href= @urltemp class="small-box-footer">more info <i class="fa fa-arrow-circle-right"></i></a>         </div>;             }         }     </div> </div><!-- /.row --> 

but when change "small-box bg-blue" @colortemp, list containing "small-box bg-blue", "small-box bg-black" , "small-box bg-green", :

first image

i suppose there subtle html specificity missed (or not), has idea what's going wrong ? edit : generated html code :

<div class="row">     <div class="col-lg-3 col-xs-6">         <!-- small box -->         <!-- achtung hier soll man vielleicht die adresse ändern -->             <div class= &#39;small-box bg-blue&#39;>                 <div class="inner">                     <h3>station</h3>                     <p> model.liststations[i]</p>                 </div>                 <div class="icon">                     <i class="fa fa-heartbeat" aria-hidden="true"></i>                 </div>                 <a href= station1 class="small-box-footer">more info <i class="fa fa-arrow-circle-right"></i></a>             </div>            <div class= &#39;small-box bg-black&#39;>                 <div class="inner">                     <h3>station</h3>                     <p> model.liststations[i]</p>                 </div>                 <div class="icon">                     <i class="fa fa-heartbeat" aria-hidden="true"></i>                 </div>                 <a href= station2 class="small-box-footer">more info <i class="fa fa-arrow-circle-right"></i></a>             </div>            <div class= &#39;small-box bg-green&#39;>                 <div class="inner">                     <h3>station</h3>                     <p> model.liststations[i]</p>                 </div>                 <div class="icon">                     <i class="fa fa-heartbeat" aria-hidden="true"></i>                 </div>                 <a href= station3 class="small-box-footer">more info <i class="fa fa-arrow-circle-right"></i></a>             </div>     </div> </div> 

to share others can encounter kind of problem, here solution.

in generated html, there &#39; instead of double-quotes.

to avoid this, have replace <div class= "small-box bg-blue"> <div class="@(colortemp)">


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -