3

Razor instruction shown below:

<td@(IsAdmin ? " class=editable name" : "") data-attr="name">it's true</td>

results in:

<td class="editable" data-attr="name" name="">it's true</td>

while I need this:

<td class="editable name" data-attr="name">it's true</td>

How to do it ?

2 Answers 2

9

How about this:

<td @Html.Raw(IsAdmin ? " class=\"editable name\"" : "") data-attr="name">it's true</td>
Sign up to request clarification or add additional context in comments.

Comments

1

Like this: @(IsAdmin ? " class=\"editable name\"" : "")

2 Comments

I've checked this before and it results in: <td class=""editable" data-attr="name" name&quot;="">it's true</td>
Using view source it gives: <td class=&quot;editable name&quot; data-attr="name">it's true</td>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.