Developer forum

Forum » Templates » If statements in razor templates

If statements in razor templates

Hans Ravnsfjall
Reply

Hi

how would I do this in a razortemplate?

 

    <!--@If(Item.Id=1)-->
  <div class="item active">
      <!--@EndIf-->

 <!--@If(Item.Id!=1)-->
        <div class="item">
          <!--@EndIf-->

 

 


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Hans

You would do like this:

@{

var classNames = "item";

if(GetInteger("Item.Id")==1){

classNames = "item active";

}

}

<div class="@classNames"></div>

Votes for this answer: 1
 
Hans Ravnsfjall
Reply

Ok, thank you

 

regards Hans

 

You must be logged in to post in the forum