I'm trying to make my razor more dynamic. I am trying to set the inline style for TDs in a table.
I made a line:
@{
double width = 100 / 5;
String widthStyleString = String.Format("style=\"width: {0}%;\"", width);
}
This works great when I tested it as plain text. I got:
style="width: 20%;"
However, when I tried to put it in an HTML element, I got the following:
<td class="table--td" style=""width:" 20%;"="">Some Value</td>
How can I make it not analyze "as an entity?" (he will not allow me to enter or insert it into the actual ")
update:
This is still a good way to make HTML attributes. However, in this case it is a style tag, user comments are correct; it is better to do this in css and not in logic. If you have this exact problem (style attribute), then the column below will help you. Otherwise, Html.Raw () is good.
Equal size table cells to fill the entire width of the hold table
, IE8 . css.