我有一個看起來像這樣條件邏輯來包裝一些HTML中Html.BeginForm
@using(Html.BeginForm(MVC.Account.Info()))
{
<p>blah blah blah</p>
<input type="submit" value="Submit!" />
}
剃刀視圖現在我只想渲染表單並提交如果User.Identity.IsAuthenticated
如果縮進水平分別顯著,可能看起來像這樣
@if(User.Identity.IsAuthenticated) // wraps the using and its open brace
{
@using(Html.BeginForm(MVC.Account.Info()))
{
}
<p>blah blah blah</p>
@if(User.Identity.IsAuthenticated) // wraps the input and the using closing brace
{
<input type="submit" value="Submit!" />
}
}
但是,當然,這種語法不起作用。有人知道一個很好的方法來做到這一點?