开发者

closing a code tag in Razor after long amounts of html

开发者 https://www.devze.com 2023-03-31 04:55 出处:网络
I have something like this: @ if(Model.Name == \"Bob\") { <div>blah blah blah</div> <table><tr><td>blah blah blah</td></tr></table>

I have something like this:

    @ if(Model.Name == "Bob")
    {
    <div>blah blah blah</div>
    <table><tr><td>blah blah blah</td></tr></table>
    }
    else
    {
    <table>
    @foreach(Something something in Model.SomethingCollection)
    {
      <div>@som开发者_高级运维thing.blah</div>
    }
<div>more html here</div>
}

that last closing "}" isn't being recognized as the close to my else block though and so it's causing a parser error.

I tried using @} but it doesn't like that. How can I reenter a code block to put in that last "}"


Have you tried removing @ before foreach ?

0

精彩评论

暂无评论...
验证码 换一张
取 消