vb.net - ASP.NET MVC3 - VB 中的 If 语句

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

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 语句?

最佳答案

@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

关于vb.net - ASP.NET MVC3 - VB 中的 If 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4173705/

相关文章:

javascript - Razor 语法和 Javascript

vb.net - VB CStr、CDate、CBool​​ 等与 DirectCast 相比,无需转换即可进行转换

C++ 变量在 "if"循环中丢失赋值

asp.net-mvc - 如何在编辑页面 MVC 中设置下拉列表选定值

function - 在 Julia 的函数作用域内的 if 语句内定义函数的结果错误

c - C 如何处理 if 语句中的非 bool 值?

asp.net-mvc - 底层 View 设置后如何访问 ViewBag.Title?

asp.net - 如何在我的 MVC3 模型绑定(bind)中包含 Telerik 文件上传?

.net - 有什么方法可以拥有一个具有替代名称的命名空间?

.net - System.Timers.Timer(.NET)真的很慢吗?