【问题标题】:ASP.NET MVC3 - If Statements in VBASP.NET MVC3 - VB 中的 If 语句
【发布时间】:2010-11-13 17:12:39
【问题描述】:

Fredrik's Blog post,他有一个C# if 语句的例子

@if (WebSecurity.IsAuthenticated) {
    <li><a href="/user/login">Log in</a></li>
} else {
    <li><a href="/user/logout">Log out</a></li>
}

但在 VB 中我似乎无法弄清楚如何做同样的事情

@If (HttpContext.Current.User.Identity.IsAuthenticated) Then
<div id="dialog-confirm" title="Log Out">
    <div class="alert" title="Alert">
    </div>
    Are you sure?</div>
End If

这表明我的内部 HTML 标记是错误的。

基本上以下是有效的

@If (HttpContext.Current.User.Identity.IsAuthenticated) Then 

End If

但是 if 语句中的任何内容都被视为“代码”而不是“标记”。我需要的是能够在其中放置标记。

有谁知道如何在 Razor VB 中做正确的 if 语句?

【问题讨论】:

标签: vb.net if-statement asp.net-mvc-3 razor


【解决方案1】:

@Lucas 为我指明了正确的方向。这似乎是有效的

@If (HttpContext.Current.User.Identity.IsAuthenticated) Then
@<div id="dialog-confirm" title="Log Out">
    <div class="alert" title="Alert"></div>
    <div>Are you sure?</div>
</div>
End If

【讨论】:

    猜你喜欢
    • 2022-06-20
    • 2012-03-29
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多