ASP.NET MVC3 - If Statements in VB

允我心安 提交于 2019-12-22 11:35:21

问题


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>
}

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

This show's that my internal HTML markup is wrong.

Basically the following is valid

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

End 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.

Does anyone know how to do a proper if statement in Razor VB?


回答1:


@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


来源:https://stackoverflow.com/questions/4173705/asp-net-mvc3-if-statements-in-vb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!