I'm using the following code to populate the table with data.
The if statement is not working as i expected. Both the statements in the conditional blocks are executed.
@if (--somecondition--)
{
<table>
foreach (Message userMessage in UserMessages)
{
<tr>
if(@userMessage.Message.MessageText.Length <= 10)
{
<td>
@userMessage.Message.MessageText
</td>
}
if(@userMessage.Message.MessageText.Length > 10)
{
<td>
@userMessage.Message.MessageText.Substring(0, 10)
</td>
}
</tr>
}
</table>
}
What am i missing here? Isnt such use not possible?
EDIT (after seeing the answer):
I thought -
Once inside code, you do not need to prefix constructs like "if" with "@"