Home Razor page, server code with html
Reply: 0

Razor page, server code with html

user949 Published in July 21, 2018, 1:44 pm

I can't figure out how to mix html with server code in this scenario.

    var i = 0;
    foreach (var match in Model.StagingRooms)
        if (i % 2 == 0)
            <div class="row">
        Html.Partial("_MatchCard", match.Value);
        if (i % 2 == 0)

Using the code above, instead of rows of cards, I get an output of my code.

If I add @ to Html.Partial and the increment

I also tried to append @ to each server code line, and removing the @{} block, however this doesn't let me compile at all. I get a bunch of red squiggles in my code.

Edit: When I add @ to every server code snippet then I get squiggles, and can't compile If I remove @ from the last if statement, then I can run the app, but that piece of code is displayed back to me in the browser page.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320221 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO