If statement problem using C# Razor View

Hi all,

I’m currently using a CMS running on .net framework building a number of Razor views to render on the page. I have a couple of other questions, though this is the easier one first :slight_smile:

For some reason, which I can’t figure out is why the error keeps saying something about ...} being out of place or not matching.

Any ideas what the problem is from the code below?
Am I missing something, need to change something because it’s a razor?

And would it be better to have an if else statement instead of two separate if statements, or the below is better, faster, more cleaner?

@{

    if ((category == "Abstract") || (category == "Poster"))
      {
          <p>Abstract or Poster show PDF</p>
          <p><a href="@d"><img src="@a" alt="@title"></a></p>
      }

    if (category == "Photograph")
      {
          <p>This is a photograph</p>
          <p><a class="popup" href="#modal"><img src="@a"></a></p>

            <div class="popup hide" id="modal">
                <img src="@b">

                @if (caption.Length != 0) {
                    <div class="img__caption">@caption</div>
                }
            </div>
      }

  }

Thanks, Barry

  if(true)
    {
        <td>@i</td>
    }

    if(ViewBag.col == 6)
    {
        </tr><tr>
    }
@for(int i = 1; i < ViewBag.numdays; i++)
{
    if(ViewBag.col == 6)
    {
        ViewBag.col = 0;
    }
    else
    {
        ViewBag.col++;
    }
}

@ruchichouhan1195 can you tell me why you think the code you’ve posted is relevant to the original question? Currently, I can’t see any connection.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.