Razor View Engine Quirks in VB.NET

后端 未结 5 1564
温柔的废话
温柔的废话 2020-12-09 16:41

I just downloaded the MVC 3.0 RC and I\'m excited to start using it, especially the Razor view engine. However, due to a few stick in the mud type people here, we are stuck

5条回答
  •  [愿得一人]
    2020-12-09 17:09

    UPDATE:

    You can use @li@genreName/li without the : because your HTML tags are self closing, if they weren't then you would need to use @: but you do not, this is clarified in the link provided by Gabe. Also, @ will also work! I would hate for people to think they need to use @: all the time because they don't, if this were the case I'd be onto Andrew nurse about this hardcore :) END UPDATE

    Here is the basic syntax for vb razor,

    The @ character starts inline expressions, single-statement blocks, and multi-statement blocks:

    ?
    
    
    @Code  Dim total = 7  End Code
    
    @Code  Dim myMessage = "Hello World" End Code
    
     
    
    

    The value of your account is: @total

    The value of myMessage is: @myMessage

                  @Code     Dim greeting = "Welcome to our site!"     Dim weekDay = DateTime.Now.DayOfWeek     Dim greetingMessage = greeting & " Today is: " & weekDay.ToString() End Code

    The greeting is: @greetingMessage

    So it should work, just close code mode at the end of the for each line and your back in HTML, this would avoid you using the @: - hunt to ellon, I think he is trying to not have to use @:

提交回复
热议问题