m.edmondson
m.edmondson

Reputation: 30922

Converting C# Razor to VB

I'm following the ASP.NET MVC Tutorial and having started in VB.NET I'm having trouble converting the following razor code:

enter image description here

I have got

<ul>
    @For Each g As MvcApplication1.Genre In Model
        <li> @g.Name </li>
    Next

</ul>

but getting

Attribute Sepcifier is not a complete statement

on both the <li> tags. I understand I need to use line continuation but can't figure out where. I'd be greatful if you can point out the problem.

Upvotes: 6

Views: 2937

Answers (3)

ntziolis
ntziolis

Reputation: 10231

Try using the text tag, which will tell razor views that the following is normal html markup, they are not actually rendered:

<ul>
    @For Each g As MvcApplication1.Genre In Model
        <text><li> @g.Name </li></text>
    Next
</ul>

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1039498

Put an @ before the li:

<ul>
    @For Each g As MvcApplication1.Genre In Model
        @<li>@g.Name</li>
    Next
</ul>

I would recommend you the following article.

Upvotes: 9

Paul
Paul

Reputation: 36349

I think your <li> line needs to be prepended with the @: operator based on this stack post:

Razor View Engine Quirks in VB.NET

Upvotes: 4

Related Questions