由网友(爸,詯崾娶她)分享简介:我在开发asp.net的MVC 3 Web应用程序。我很新的给它。在使用剃须刀一个看法,我想声明一些局部变量,并用它在整个页面。如何才能做到这一点?I am developing a web application in asp.net mvc 3.I am very new to it. In a view u...
我在开发asp.net的MVC 3 Web应用程序。 我很新的给它。在使用剃须刀一个看法,我想声明一些局部变量,并用它在整个页面。如何才能做到这一点?
I am developing a web application in asp.net mvc 3. I am very new to it. In a view using razor, I'd like to declare some local variables and use it across the entire page. How can this be done?
这似乎很微不足道的可以做以下动作:
It seems rather trivial to be able to do the following action:
@bool isUserConnected = string.IsNullOrEmpty(Model.CreatorFullName);
@if (isUserConnected)
{ // meaning that the viewing user has not been saved
<div>
<div> click to join us </div>
<a id="login" href="javascript:void(0);" style="display: inline; ">join</a>
</div>
}
但是,这并不正常工作。这可能吗?
But this doesn't work. Is this possible?
推荐答案
我觉得你是pretty的接近,试试这个:
I think you were pretty close, try this:
@{bool isUserConnected = string.IsNullOrEmpty(Model.CreatorFullName);}
@if (isUserConnected)
{ // meaning that the viewing user has not been saved
<div>
<div> click to join us </div>
<a id="login" href="javascript:void(0);" style="display: inline; ">join</a>
</div>
}
相关推荐
最新文章