I have used following code to add css class:
<div id="123" class="tab-pane @{ if (some_condition) { Html.Raw("active"); }; } ">
But it did not work.
I hope for this result:
<div id="123" class="tab-pane active">
I have used following code to add css class:
<div id="123" class="tab-pane @{ if (some_condition) { Html.Raw("active"); }; } ">
But it did not work.
I hope for this result:
<div id="123" class="tab-pane active">
@MichaelPerrenoud's answer is close. You need to wrap the whole conditional in parenthesis.
Using @() tells razor to output a string. So
<div id="123" class='tab-pane @(condition ? "active" : "")'>
I believe you may be wanting to do this:
<div id="123" class='tab-pane @some_condition ? "active" : ""'>
you can add javascript code
<script>
@if(true)
$('#123').addClass("active");
</script>