ASP.NET MVC3 - 如果VB中的语句 [英] ASP.NET MVC3 - If Statements in VB
本文介绍了ASP.NET MVC3 - 如果VB中的语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Fredrik的博客文章,他有一个C#if语句的例子
In Fredrik's Blog post, he has an example of a C# if statement
@if (WebSecurity.IsAuthenticated) {
<li><a href="/user/login">Log in</a></li>
} else {
<li><a href="/user/logout">Log out</a></li>
}
但在VB中我似乎无法弄清楚如何做同样的事情事情
But in VB I can't seem to figure out how to do the same thing
@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标记错误。
This show's that my internal HTML markup is wrong.
基本上以下是有效的
@If (HttpContext.Current.User.Identity.IsAuthenticated) Then
End If
但if语句内的任何内容被认为是代码而不是标记。我需要的是能够将标记放在那里。
but anything that goes inside the if statement is considered "code" and not "markup". What I need is to be able to put markup in there.
有没有人知道如何在Razor VB中做一个正确的if语句?
Does anyone know how to do a proper if statement in Razor VB?
推荐答案
@Lucas指出我正确的方向。这似乎是有效的
@Lucas pointed me in the right direction. This seems to be valid
@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
这篇关于ASP.NET MVC3 - 如果VB中的语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文