带有razor语法的ASP.NET vbhtml为DateTime.Now.DayOfWeek提供了错误的答案?

时间:2016-04-07 11:06:27

标签: asp.net razor webmatrix

<!-- Multi-statement block --> 
@Code
dim greeting = "Welcome to our site!" 
dim weekDay = DateTime.Now.DayOfWeek 
dim greetingMessage = greeting & " Here in Huston it is: " & weekDay
End Code

<p>The greeting is: @greetingMessage</p> 

周日显示&#39; 4&#39;这是当月,但单独使用时没有&#39;&amp;&#39;像这样

dim greetingMessage = weekDay

OR

<p>@DateTime.Now.DayOfWeek</p>

然后显示正确的工作日。

1 个答案:

答案 0 :(得分:0)

两种方式都是一样的。在第一个场景中,4不是月份。这是周四的数字。使用weekDay.ToString()。

 <!-- Multi-statement block -->
    @Code
        Dim greeting = "Welcome to our site!"
        Dim weekDay = DateTime.Now.DayOfWeek
        Dim greetingMessage = greeting & " Here in Huston it is: " & weekDay.ToString()
    End Code